View Code of Problem 135

#include<iostream>
using namespace std;
int main(){
	int M;
	while(cin>>M){
		int X=0,Y=0;
		while(M--){
			string s;
			cin>>s;
			string num=s.substr(1);
			int step=stoi(num);
			switch(s[0]){
				case 'L':
					X-=step;
					break;
				case 'R':
					X+=step;
					break;
				case 'F':
					Y+=step;
					break;
				case 'B':
					Y-=step;
 			}
		}
		int fx,fy;
		cin>>fx>>fy;
		if(X==fx && Y==fy){
			cout<<"MEME IS SO LUCKY"<<endl;
		}
		else{
			cout<<"GPS ERROR"<<endl;
		}
	}
}

Double click to view unformatted code.


Back to problem 135