Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <bitset>
- using namespace std;
- int main()
- {
- int m,n,s,w,e,x,y;
- bitset<100> nf, ef, wf ,sf;
- while(cin >> m >> n >> s >> w >> e >> x >> y && m){
- nf.reset();
- ef.reset();
- wf.reset();
- sf.reset();
- x--;
- y--;
- int f,walked=0;
- while(n-- && cin >> f)
- nf[f-1]=true;
- while(s-- && cin >> f)
- sf[f-1]=true;
- while(w-- && cin >> f)
- wf[f-1]=true;
- while(e-- && cin >> f)
- ef[f-1]=true;
- while(walked++!=m*m+1){
- if(x >= m || y >= m || x < 0 || y < 0){
- cout << "Be careful" << endl;
- break;
- }else if((nf[x]^sf[x])||(wf[y]^ef[y])){
- int oy=y;
- if(nf[x]^sf[x])
- y+=nf[x]?-1:1;
- if(wf[oy]^ef[oy])
- x+=ef[oy]?-1:1;
- }else{
- cout << x+1 << ' ' << y+1 << endl;
- break;
- }
- }
- if(walked>=m*m+1)
- cout << "Busy Bob" << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment