Submission #1157547

#TimeUsernameProblemLanguageResultExecution timeMemory
1157547mocha영역 (JOI16_ho_t4)C++20
15 / 100
940 ms327680 KiB
#include <bits/stdc++.h> using namespace std; const int mx = 1e5+5; int n, k; string s; set<pair<int, int>> st; char c[4] = {'E', 'N', 'W', 'S'}; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; signed main() { cin >> n >> k; cin >> s; int x = 0, y = 0; st.insert({x, y}); for (int i=0;i<k;i++) { for (int j=0;j<n;j++) { for (int k=0;k<4;k++) { if (s[j] == c[k]) { x += dx[k]; y += dy[k]; break; } } st.insert({x, y}); } } int ans = 0; for (auto [x, y]:st) { if (st.count({x+1, y}) and st.count({x, y+1}) and st.count({x+1, y+1})) { ans++; } } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...