View Code of Problem 135

#include<bits/stdc++.h>
using namespace std;

int main(){
	int m;
	while(cin>>m){
		getchar();
		int hpos=0,epos=0;
		while(m--){
			char s[20];
			gets(s);
			int j=s[1]-'0';
			for(int i=2;i<strlen(s);i++){
				j=j*10+s[i]-'0';
			}
			if(s[0]=='L') hpos-=j;
			else if(s[0]=='R') hpos+=j;
			else if(s[0]=='F') epos+=j;
			else if(s[0]=='B') epos-=j;
		}
		int x,y;
		cin>>x>>y;
		if(hpos==x&&epos==y){
			cout<<"MEME IS SO LUCKY"<<endl;
		}else{
			cout<<"GPS ERROR"<<endl;
		}
	}
}

Double click to view unformatted code.


Back to problem 135