#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 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... |