Submission #4263449
Source Code Expand
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))
using namespace std;
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
// Problem Specific Parameter:
int main() {
string s; cin >> s;
int a[4] = {0};
for(int i = 0; i < s.length(); i++) {
if(s[i] == 'N') a[0]++;
else if(s[i] == 'S') a[1]++;
else if(s[i] == 'W') a[2]++;
else if(s[i] == 'E') a[3]++;
}
if(a[0] == a[1] && a[0] == 0) {
if(a[2] == 0 && a[2] == a[3]) cout << "Yes" << endl;
else if(a[2] > 0 && a[3] > 0) cout << "Yes" << endl;
else cout << "No" << endl;
} else if(a[2] == a[3] && a[2] == 0) {
if(a[0] == a[1] && a[0] == 0) cout << "Yes" << endl;
else if(a[0] > 0 && a[1] > 0) cout << "Yes" << endl;
else cout << "No" << endl;
} else if(a[0] > 0 && a[1] > 0 && a[2] > 0 && a[3] > 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Wanna go back home |
User |
atsuyoshi |
Language |
C++14 (GCC 5.4.1) |
Score |
200 |
Code Size |
1956 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 |