Problem Help Why are test cases getting failed

Revision en2, by hrithikjos56, 2021-03-14 11:28:28

Problem link

https://mirror.codeforces.com/contest/1351/problem/C

submission link https://mirror.codeforces.com/contest/1351/submission/109952345

include <bits/stdc++.h>

using namespace std;

define ios ios::sync_with_stdio(false); cin.tie(NULL);

define ll long long

define MOD 1000000007

int main() { ios;

ll t;

cin>>t;

while(t--) 
 {

string s;  

  cin>>s;

ll x = 0,y=0,n = s.size();

map<pair<ll,ll>,bool>mp;

ll ans = 0;

for(ll i=0;i<n;i++)

{

   mp[{x,y}] = 1;

    if(s[i] == 'N') y+= 1;

    else if(s[i] == 'S') y -= 1;

    else if(s[i] == 'E') x += 1;

    else if(s[i] == 'W') x -= 1;


    if(mp[{x,y}] == 1)   

      ans += 1;

    else 

       ans += 5;  

}

   cout<<ans<<endl;

 }

return 0;

}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English hrithikjos56 2021-03-14 11:28:28 35
en1 English hrithikjos56 2021-03-14 11:27:46 926 Initial revision (published)