Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- long long size, a, b, cnt=1, cntmax=0;
- int vtx[8]={-2, -1, 1, 2, 2, 1, -1, -2},
- vty[8]={1 , 2 , 2, 1, -1, -2, -2, -1};
- bool used[505][505];
- void init()
- {
- for(int i=0; i<=504; i++)
- {
- for(int j=0; j<=504; j++)
- {
- used[i][j]=true;
- }
- }
- for(int i=1; i<=size; i++)
- {
- for(int j=1; j<=size; j++)
- {
- used[i][j]=false;
- }
- }
- used[a][b]=true;
- }
- //back//
- void back(int i)
- {
- for(int j=0; j<=7; j++)
- {
- if((a+vtx[j]>0&&b+vty[j]>0&&a+vtx[j]<=size&&b+vty[j]<=size)&&used[a+vtx[j]][b+vty[j]]==false)
- {
- a+=vtx[j];
- b+=vty[j];
- used[a][b]=true;
- //cout<<a<<" "<<b<<" "<<endl;
- back(i+1);
- used[a][b]=false;
- a-=vtx[j];
- b-=vty[j];
- }
- }
- //cout<<i<<endl;
- if(i>cntmax)
- {
- cntmax=i;
- }
- }
- int main()
- {
- cin>>size>>a>>b;
- init();
- back(1);
- cout<<cntmax;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement