Twoim kodem dostalem AC, jestes blisko celu ;)
if (x==0 && y==0) cout<<"studnia\n";
else if(x==0 && y>0) cout<<0<<" "<<y<<endl;
else if(x==0 && y<0) cout<<1<<" "<<abs(y)<<endl;
else if(y==0 && x>0) cout<<3<<" "<<y<<endl; // czemu y ?
else if(y==0 && x<0) cout<<2<<" "<<abs(y)<<endl; // i tu