Submission #775606

#TimeUsernameProblemLanguageResultExecution timeMemory
775606hgmhc영역 (JOI16_ho_t4)C++17
15 / 100
127 ms5192 KiB
#include <bits/stdc++.h> #define rep(i,a,b) for (auto i = (a); i <= (b); ++i) #define per(i,a,b) for (auto i = (b); i >= (a); --i) #define all(x) begin(x),end(x) #define siz(x) int((x).size()) #define Mup(x,y) x = max(x,y) #define mup(x,y) x = min(x,y) #define dbg(...) fprintf(stderr,__VA_ARGS__) #define fi first #define se second using namespace std; using ll = long long; using ii = pair<int,int>; const int N = 1e5+3; int n, k; char s[N]; set<ii> c, a; bool make_square(int x, int y) { rep(i,0,1) rep(j,0,1) if (not c.count({x+i,y+j})) return false; return true; } int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> k >> &s[1]; int x = 0, y = 0; c.insert({0,0}); rep(i,1,n) { if (s[i] == 'E') { c.insert({x,++y}); } else if (s[i] == 'W') { c.insert({x,--y}); } else if (s[i] == 'N') { c.insert({++x,y}); } else if (s[i] == 'S') { c.insert({--x,y}); } else assert(0); rep(i,-1,1) rep(j,-1,1) { if (make_square(x+i,y+j)) a.insert({x+i,y+j}); } } printf("%d", siz(a)); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...