@hemanth_1995 wrote:
I am getting w a even after doing many things
I referred all FAQ related to this question for test cases
Please someone help me !here is my code
include
include
using namespace std;
class position
{
public:
long unsigned int x;
long unsigned int y;
long unsigned int z;
} pos[2000];int main()
{
unsigned int test,a[2000],b[2000],i,j,flag=0;cin >> test; for(i=0;i<=2000;i++) { pos[i].x=0; pos[i].y=0; pos[i].z=0; } for(i=0;i<test;i++) { cin >> a[i] >> b[i]; } for(i=1;i<=2000;i++) { if(i%4==1) { pos[i].x=pos[i-1].x+1; pos[i].y=pos[i-1].y+1; pos[i].z=i; } if(i%4==2) { pos[i].x=pos[i-1].x+1; pos[i].y=pos[i-1].y-1; pos[i].z=i; } if(i%4==3) { pos[i].x=pos[i-1].x+1; pos[i].y=pos[i-1].y+1; pos[i].z=i; } if(i%4==0) { pos[i].x=(pos[i-1].x)-1; pos[i].y=(pos[i-1].y)+1; pos[i].z=i; } } for(i=0;i<test;i++) { for(j=0;j<=2000;j++) { if(a[i]==pos[j].x && b[i]==pos[j].y) { cout << pos[j].z<<"\n"; flag=0; break; } else flag=1; } if(flag==1) cout <<"No Number"<<"\n"; } return 0;
}
included library are
iostream
and stdio.h