# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
117168 | onjo0127 | 영역 (JOI16_ho_t4) | C++11 | 49 ms | 5248 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
Compilation message (stderr)
# | 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... |