View Code of Problem 135

#include <map>
#include "stdlib.h"
#include<stdio.h>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
#include <iomanip>
#include "math.h"
using namespace std;
map<char, int> mp;

int main()
{
	int m,l,r; string str;
	while (cin >> m)
	{
		int x = 0,y=0;
		for (int i = 0; i < m; i++)
		{
			cin >> str; int j;
			if (str[0] == 'L')
			{
				str.erase(str.begin());
				j = atoi(str.c_str());
				x -= j;
			}
			else if (str[0] == 'R')
			{
				str.erase(str.begin());
				j = atoi(str.c_str());
				x += j;
			}
			else if (str[0] == 'F')
			{
				str.erase(str.begin());
				j = atoi(str.c_str());
				y += j;
			}
			else if (str[0] == 'B')
			{
				str.erase(str.begin());
				j = atoi(str.c_str());
				y -= j;
			}
		}
		cin >> l >> r;
		if (x == l && y == r)cout << "MEME IS SO LUCKY";
		else cout << "GPS ERROR";
		cout << endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 135