View Code of Problem 135

#include<stdio.h>
#include<math.h>
#include<string.h>
//#include<algorithm>
#include <bits/stdc++.h>

using namespace std;

int main() {
	int n,i,j;
	char c;
	int num;
	char temp[100];
	while(scanf("%d",&n)!=EOF) {
		int x=0,y=0;
		for(i=0; i<n; i++) {
			num=0;
			scanf("%s",temp);
			c=temp[0];
			for(j=1; j<strlen(temp);j++) {
				num=num*10+temp[j]-'0';
			}
//			scanf("%c%d",&c,&num);
//			printf("%c %d",c,num);
			if(c=='L') {
				x=x-num;
			} else if(c=='F') {
				y=y+num;
			} else if(c=='R') {
				x=x+num;
			} else {
				y=y-num;
			}
		}
//		printf("%d %d\n",x,y);
		int resx,resy;
		scanf("%d %d",&resx,&resy);
//		printf("%d-%d\n",resx,resy);
		if(x==resx&&y==resy) {
			printf("MEME IS SO LUCKY\n");
		} else {
			printf("GPS ERROR\n");
		}

	}

}

Double click to view unformatted code.


Back to problem 135