View Code of Problem 135

#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <stack>
#include <map>
#include <set>
#include <queue>
using namespace std;

void change(string &a,int &x,int &y)
{
    char p=a[0];
    a.erase(a.begin());
    int len=a.size();
    int kk=0;
    for(int i=0;i<len;i++)
    {
        kk=kk*10+a[i];
    }
    if(p=='L') x-=kk;
    if(p=='R') x+=kk;
    if(p=='F') y+=kk;
    if(p=='B') y-=kk;
}

int main()
{
    #ifdef  ONLINE_JUDGE
    #else
    freopen("1.txt","r",stdin);
    #endif
    int n;
    while(cin>>n)
    {
        int x=0,y=0;
        while(n--)
        {
            string str;
            cin>>str;
            change(str,x,y);
        }
        int a,b;
        cin>>a>>b;
        if(a==x&&b==y)
        {
            cout<<"MEME IS SO LUCKY"<<endl;
        }
        else cout<<"GPS ERROR"<<endl;
    }



    return 0;
}

Double click to view unformatted code.


Back to problem 135