View Code of Problem 135

#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;
int main(void){
	
	int move[26][2]={0};
	move['L'-'A'][0] = -1;
	move['L'-'A'][1] = 0;
	move['R'-'A'][0] = 1;
	move['R'-'A'][1] = 0;
	move['F'-'A'][0] = 0;
	move['F'-'A'][1] = 1;
	move['B'-'A'][0] = 0;
	move['B'-'A'][1] = -1;
	
	int n;
	while(~scanf("%d",&n)){
        int position[2]={0};
          int target[2]={0};
		int a;
		char c;
		for(int i = 0;i < n;i++){
			getchar();
			scanf("%c%d",&c,&a);
			position[0] += a*move[c-'A'][0];
			position[1] += a*move[c-'A'][1];
		}
		scanf("%d %d",target,target+1);
		if(target[0] == position[0] && target[1] == position[1]){
			printf("MEME IS SO LUCKY\n");
		}else
			printf("GPS ERROR\n");
	}
}

Double click to view unformatted code.


Back to problem 135