Submission #137084

#TimeUsernameProblemLanguageResultExecution timeMemory
137084arnold518영역 (JOI16_ho_t4)C++14
15 / 100
71 ms5280 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

#define x first
#define y second

int N, K, ans;
char S[MAXN+10];
set<pii> ST;

int main()
{
    int i, j;

    scanf("%d%d%s", &N, &K, S+1);
    pii now={0, 0}; ST.insert(now);
    for(i=1; i<=N; i++)
    {
        if(S[i]=='N') now.y++;
        else if(S[i]=='S') now.y--;
        else if(S[i]=='W') now.x--;
        else now.x++;
        ST.insert(now);
    }

    for(auto it : ST) ans+=(ST.count({it.x, it.y}) && ST.count({it.x+1, it.y}) && ST.count({it.x, it.y+1}) && ST.count({it.x+1, it.y+1}));
    printf("%d", ans);
}

Compilation message (stderr)

2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:19:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
2016_ho_t4.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%s", &N, &K, S+1);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...