View Code of Problem 135

#include<iostream>
using namespace std;
int main() {
	int M, x,y, x0, y0;
	while(cin>>M) {
		string s;
		x0=y0=0;
		for(int i=0; i<M; i++) {
			cin>>s;
			if(s[0]=='L') {
				x0-=s[1]-'0';
			}else if(s[0]=='R') {
				x0+=s[1]-'0';
			}else if(s[0]=='F') {
				y0+=s[1]-'0';
			}else if(s[0]=='B'){
				y0-=s[1]-'0';
			}
		}
		cin>>x>>y;
		if(x0==x&&y0==y) cout<<"MEME IS SO LUCKY"<<endl;
		else cout<<"GPS ERROR"<<endl;
	}
}

Double click to view unformatted code.


Back to problem 135