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>
#define pb push_back
#define eb emplace_back
#define in insert
#define ld long double
#define ll long long
#define pii pair<ll,ll>
#define vl vector<ll>
#define mpr make_pair
#define F first
#define S second
#define lg(a) __lg(a)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define LMX LLONG_MAX
using namespace std;
const int mod = 1e9+7;
const int sz = 505;
const ll oo = 1000000000000000005;
char a[sz][sz];
void solve(){
ll n,m,i,j;
cin>>n>>m;
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
cin>>a[i][j];
}
}
if(n==1){
ll cur=0;
for(i=1;i<m;i++){
if(a[1][i]=='N'){cur++;}
else if(a[1][i]=='E'){continue;}
else if(a[1][i]=='S'){cur+=3;}
else if(a[1][i]=='W'){cur+=2;}
else{cout<<-1<<endl;return ;}
}
cout<<cur<<endl;
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll t=1;
//cin>>t;
while(t--){
solve();
}
}
# | 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... |