Submission #1135302

#TimeUsernameProblemLanguageResultExecution timeMemory
1135302mmdrzadaNautilus (BOI19_nautilus)C++20
0 / 100
2 ms324 KiB
// Nautilus // Village // Alphine walley #include <bits/stdc++.h> using namespace std; #define vi vector<int> #define REP(i, k) for(int i = 0 ; i < k ; i ++) #define pb push_back #define pii pair<int, int> #define ll long long #define sep ' ' #define F first #define S second const int N = 102; int r, c, m; string s[N]; string t; pii change(pii curr, char c) { if (c == 'N') curr.F--; else if (c == 'S') curr.F++; if (c == 'E') curr.S++; if (c == 'W') curr.S--; return curr; } bool valid(int i, int j) { return 0 <= i && i < r && 0 <= j && j < c; } bool check(int i, int j) { if (s[i][j] == '#') return false; pii curr = {i, j}; for(char c: t) { pii ne = change(curr, c); if (valid(ne.F, ne.S) && s[ne.F][ne.S] != '#') curr = ne; else return false; } return true; } void solve() { cin >> r >> c >> m; REP(i, r) cin >> s[i]; cin >> t; reverse(t.begin(), t.end()); int cnt = 0; REP(i, r) { REP(j, c) { if (check(i, j)) cnt++; } } cout << cnt << endl; } int32_t main() { solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...