This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int m, n;
cin >> m >> n;
string s[m];
for(int i = 0; i < m; i++) {
cin >> s[i];
}
map<pair<char, char>, int> M;
M[{'N', 'E'}] = 1;
M[{'E', 'S'}] = 1;
M[{'S', 'W'}] = 1;
M[{'W', 'N'}] = 1;
M[{'N', 'S'}] = 2;
M[{'E', 'W'}] = 2;
M[{'S', 'N'}] = 2;
M[{'W', 'E'}] = 2;
M[{'N', 'W'}] = 3;
M[{'E', 'N'}] = 3;
M[{'S', 'E'}] = 3;
M[{'W', 'S'}] = 3;
if(m == 1) {
bool w = 1;
int S = 0;
for(int i = 0; i < n; i++) {
if(s[0][i] == 'x') {
w = 0;
break;
}
if(s[0][i] != 'E') {
S += M[{s[0][i], 'E'}];
}
}
cout << (w ? S : -1) << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |