#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m; cin >> n >> m;
string s = "", t;
while (--n)
{
cin >> t;
s += t;
}
int ans = 0;
bool pos = true;
for (char c : s)
{
ans += (c == 'N' ? 2 : (c == 'E' || c == 'W' ? 1 : 0));
if (c == 'X') pos = false;
}
cout << (pos ? ans : -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... |