제출 #117168

#제출 시각아이디문제언어결과실행 시간메모리
117168onjo0127영역 (JOI16_ho_t4)C++11
15 / 100
49 ms5248 KiB
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

set<pii> st;
char S[100009];

int cnt(set<pii>& S) {
    int ret = 0;
    for(auto& it: S) {
        int x, y; tie(x, y) = it;
        if(S.find({x+1, y}) != S.end() && S.find({x, y+1}) != S.end() && S.find({x+1, y+1}) != S.end()) ++ret;
    }
    return ret;
}

int main() {
    int N, K; scanf("%d%d",&N,&K);
    int x = 0, y = 0; st.insert({0, 0});
    for(int i=1; i<=N; i++) {
        scanf(" %c",&S[i]);
        if(S[i] == 'N') ++y;
        if(S[i] == 'S') --y;
        if(S[i] == 'E') ++x;
        if(S[i] == 'W') --x;
        st.insert({x, y});
    }
    printf("%d", cnt(st));
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:18:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int N, K; scanf("%d%d",&N,&K);
               ~~~~~^~~~~~~~~~~~~~
2016_ho_t4.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c",&S[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...