Submission #51174

# Submission time Handle Problem Language Result Execution time Memory
51174 2018-06-17T04:24:22 Z 노영훈(#1283, Diuven) None (JOI16_ho_t4) C++11
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int MX=100010, inf=2e9;

int n, k;
char S[MX];

map<pii, bool> B, C;

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    assert(k==1);
    cin>>(S+1);
    B[pii(0,0)]=true;
    for(int i=1, x=0, y=0; i<=n; i++){
        if(S[i]=='N') y++;
        if(S[i]=='S') y--;
        if(S[i]=='E') x++;
        if(S[i]=='W') x--;
        B[pii(x,y)]=true;
    }
    int ans=0;
    C[pii(0,0)]=true;
    for(int i=1, x=0, y=0; i<=n; i++){
        if(S[i]=='N') y++;
        if(S[i]=='S') y--;
        if(S[i]=='E') x++;
        if(S[i]=='W') x--;
        if(!C[pii(x,y)] && B[pii(x,y)] && B[pii(x+1,y)] && B[pii(x,y+1)] && B[pii(x+1,y+1)]) ans++;
        C[pii(x,y)]=true;
    }
    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -