# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
362921 | 2021-02-04T17:48:47 Z | aujasvit_datta | Nautilus (BOI19_nautilus) | C++14 | 5 ms | 876 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define pii pair<int, int> #define fr first #define sc second #define all(a) a.begin(),a.end() int r,c,m; string s; string grid[102]; set <pii> ans; bool can_happen(int row, int col) { int cr = row, cc = col; for(int i = 0; i < s.size(); i++) { if(s[i] == 'W') { if(cc != 0 and grid[cr][cc - 1] != '#') { cc--; } else { return false; } } else if(s[i] == 'S') { if(cr != r and grid[cr + 1][cc] != '#') { cr++; } else { return false; } } else if(s[i] == 'N') { if(cr != 1 and grid[cr - 1][cc] != '#') { cr--; } else { return false; } } else if(s[i] == 'E') { if(cc != c - 1 and grid[cr][cc + 1] != '#') { cc++; } else { return false; } } } ans.insert(mp(cr,cc)); return true; } int count() { for(int i = 1; i <= r; i++) { for(int j = 0; j < c; j++) { if(grid[i][j] != '#' and can_happen(i, j)) { //do nothing } } } return ans.size(); } signed main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); cin >> r >> c >> m; for(int i = 1; i <= r; i++) { cin >> grid[i]; } cin >> s; cout << count(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 876 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 876 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Incorrect | 5 ms | 876 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 876 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Incorrect | 5 ms | 876 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |