# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
730650 | 2023-04-26T08:36:29 Z | gagik_2007 | Nautilus (BOI19_nautilus) | C++17 | 1000 ms | 1236 KB |
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <cmath> #include <chrono> #include <ctime> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <limits> #include <iomanip> #include <unordered_set> #include <unordered_map> #include <fstream> #include <functional> #include <random> #include <cassert> using namespace std; typedef long long ll; typedef long double ld; #pragma GCC optimize("Ofast") #define ff first #define ss second ll ttt; const ll INF = 1e18; const ll MOD = 1e9 + 7; const ll N = 507; const ll LG = 21; ll n, m, k; char a[N][N]; string s; bool dp[N][N]; bool lst[N][N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m >> k; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; if (a[i][j] == '.') { dp[i][j] = true; } } } for (int i = 0; i <= n + 1; i++) { a[i][0] = a[i][m + 1] = '#'; } for (int j = 0; j <= m + 1; j++) { a[0][j] = a[n + 1][j] = '#'; } cin >> s; for (int c = 0; c < s.size(); c++) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { lst[i][j] = dp[i][j]; dp[i][j] = false; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (lst[i][j]) { if (s[c] == 'N' || s[c] == '?') { if (a[i - 1][j] == '.') { dp[i - 1][j] = true; } } if (s[c] == 'E' || s[c] == '?') { if (a[i][j + 1] == '.') { dp[i][j + 1] = true; } } if (s[c] == 'S' || s[c] == '?') { if (a[i + 1][j] == '.') { dp[i + 1][j] = true; } } if (s[c] == 'W' || s[c] == '?') { if (a[i][j - 1] == '.') { dp[i][j - 1] = true; } } } } } } int cnt = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cnt += dp[i][j]; } } cout << cnt << endl; } /// ---- - -------- ------ -------- -- - - - /// Just a reminder. Ubuntu password is I O I /// ---- - -------- ------ -------- -- - - -
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 464 KB | Output is correct |
2 | Correct | 2 ms | 468 KB | Output is correct |
3 | Correct | 2 ms | 472 KB | Output is correct |
4 | Correct | 2 ms | 468 KB | Output is correct |
5 | Correct | 2 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 464 KB | Output is correct |
2 | Correct | 2 ms | 468 KB | Output is correct |
3 | Correct | 2 ms | 472 KB | Output is correct |
4 | Correct | 2 ms | 468 KB | Output is correct |
5 | Correct | 2 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 468 KB | Output is correct |
7 | Correct | 4 ms | 492 KB | Output is correct |
8 | Correct | 4 ms | 468 KB | Output is correct |
9 | Correct | 2 ms | 468 KB | Output is correct |
10 | Correct | 2 ms | 468 KB | Output is correct |
11 | Correct | 2 ms | 468 KB | Output is correct |
12 | Correct | 5 ms | 468 KB | Output is correct |
13 | Correct | 8 ms | 468 KB | Output is correct |
14 | Correct | 9 ms | 468 KB | Output is correct |
15 | Correct | 2 ms | 468 KB | Output is correct |
16 | Correct | 3 ms | 468 KB | Output is correct |
17 | Correct | 6 ms | 492 KB | Output is correct |
18 | Correct | 10 ms | 468 KB | Output is correct |
19 | Correct | 7 ms | 468 KB | Output is correct |
20 | Correct | 3 ms | 468 KB | Output is correct |
21 | Correct | 1 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 464 KB | Output is correct |
2 | Correct | 2 ms | 468 KB | Output is correct |
3 | Correct | 2 ms | 472 KB | Output is correct |
4 | Correct | 2 ms | 468 KB | Output is correct |
5 | Correct | 2 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 468 KB | Output is correct |
7 | Correct | 4 ms | 492 KB | Output is correct |
8 | Correct | 4 ms | 468 KB | Output is correct |
9 | Correct | 2 ms | 468 KB | Output is correct |
10 | Correct | 2 ms | 468 KB | Output is correct |
11 | Correct | 2 ms | 468 KB | Output is correct |
12 | Correct | 5 ms | 468 KB | Output is correct |
13 | Correct | 8 ms | 468 KB | Output is correct |
14 | Correct | 9 ms | 468 KB | Output is correct |
15 | Correct | 2 ms | 468 KB | Output is correct |
16 | Correct | 3 ms | 468 KB | Output is correct |
17 | Correct | 6 ms | 492 KB | Output is correct |
18 | Correct | 10 ms | 468 KB | Output is correct |
19 | Correct | 7 ms | 468 KB | Output is correct |
20 | Correct | 3 ms | 468 KB | Output is correct |
21 | Correct | 1 ms | 468 KB | Output is correct |
22 | Execution timed out | 1065 ms | 1236 KB | Time limit exceeded |
23 | Halted | 0 ms | 0 KB | - |