Submission #1731931
Source Code Expand
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979
typedef long long Int;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
const int INF = 1000000000;
const int MAX = 2007;
const int ADD = 500107;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
bool b[4];
int id(char c)
{
if (c == 'N') return 3;
if (c == 'S') return 2;
if (c == 'E') return 1;
if (c == 'W') return 0;
}
int main()
{
//freopen("in.txt", "r", stdin);
string s;
cin >> s;
int x = 0, y = 0;
FOR (i,0,SZ(s))
{
int d = id(s[i]);
x += dx[d];
y += dy[d];
b[d] = 1;
}
bool ok = 1;
if (x < 0 && b[1] == 0) ok = 0;
if (x > 0 && b[0] == 0) ok = 0;
if (y < 0 && b[3] == 0) ok = 0;
if (y > 0 && b[2] == 0) ok = 0;
cout << (ok ? "Yes" : "No") << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Wanna go back home |
User |
vjudge1 |
Language |
C++14 (GCC 5.4.1) |
Score |
200 |
Code Size |
1568 Byte |
Status |
AC |
Exec Time |
1 ms |
Memory |
256 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
200 / 200 |
Status |
|
|
Set Name |
Test Cases |
Sample |
s1.txt, s2.txt, s3.txt, s4.txt |
All |
01.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 13.txt, 15.txt, s1.txt, s2.txt, s3.txt, s4.txt |
Case Name |
Status |
Exec Time |
Memory |
01.txt |
AC |
1 ms |
256 KB |
04.txt |
AC |
1 ms |
256 KB |
05.txt |
AC |
1 ms |
256 KB |
06.txt |
AC |
1 ms |
256 KB |
07.txt |
AC |
1 ms |
256 KB |
08.txt |
AC |
1 ms |
256 KB |
09.txt |
AC |
1 ms |
256 KB |
10.txt |
AC |
1 ms |
256 KB |
11.txt |
AC |
1 ms |
256 KB |
13.txt |
AC |
1 ms |
256 KB |
15.txt |
AC |
1 ms |
256 KB |
s1.txt |
AC |
1 ms |
256 KB |
s2.txt |
AC |
1 ms |
256 KB |
s3.txt |
AC |
1 ms |
256 KB |
s4.txt |
AC |
1 ms |
256 KB |