#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define pf push_front
#define in insert
#define all(v) v.begin(),v.end()
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int sz=1000000,INF=1000000000;
using namespace std;
void solve()
{
ll n,m,ans=0;
char c;
cin>>n>>m;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>c;
if(c!='N')
{
if(c=='W')
{
ans++;
}
else if(c=='E')
{
ans+=3;
}
else
{
ans+=2;
}
}
}
}
cout<<ans;
}
int main()
{
fastIO;
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... |