# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
625234 | 2022-08-09T16:39:22 Z | Do_you_copy | Nautilus (BOI19_nautilus) | C++17 | 180 ms | 984 KB |
#include <bits/stdc++.h> //#define int long long #define fi first #define se second #define pb push_back #define faster ios_base::sync_with_stdio(0); cin.tie(0); using namespace std; using ll = long long; using ull = unsigned ll; using ld = long double; using pii = pair <int, int>; using pil = pair <int, ll>; using pli = pair <ll, int>; using pll = pair <ll, ll>; mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count()); ll min(const ll &a, const ll &b){ return (a < b) ? a : b; } ll max(const ll &a, const ll &b){ return (a > b) ? a : b; } //const ll Mod = 1000000007; //const ll Mod2 = 999999999989; //only use when required const int maxN = 501 + 1; int r, c, m; string s[maxN]; string t; bitset <500> a[maxN]; bitset <500> dp[501][2]; void Init(){ cin >> r >> c >> m; for (int i = 0; i < r; ++i){ cin >> s[i]; for (int j = 0; j < c; ++j){ a[i][j] = s[i][j] == '.'; dp[i][0] = a[i]; } } cin >> t; for (int k = 1; k <= m; ++k){ for (int i = 0; i < r; ++i){ int j = k % 2; dp[i][j] = 0; if ((t[k - 1] == 'S' || t[k - 1] == '?') && i > 0) dp[i][j] |= dp[i - 1][j ^ 1] & a[i]; if (t[k - 1] == 'W' || t[k - 1] == '?') dp[i][j] |= (dp[i][j ^ 1] >> 1) & a[i]; if (t[k - 1] == 'E' || t[k - 1] == '?') dp[i][j] |= (dp[i][j ^ 1] << 1) & a[i]; if ((t[k - 1] == 'N' || t[k - 1] == '?') && i < r - 1) dp[i][j] |= dp[i + 1][j ^ 1] & a[i]; } } int ans = 0; for (int i = 0; i < r; ++i){ ans += dp[i][m % 2].count(); } cout << ans << "\n"; } #define debu #define taskname "test" signed main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); #ifdef debug freopen(taskname".out", "w", stdout); #endif } faster; ll tt = 1; //cin >> tt; while (tt--){ Init(); } if (fopen("timeout.txt", "r")){ ofstream timeout("timeout.txt"); timeout << 1000 * double(clock()) / CLOCKS_PER_SEC; #ifndef debug cerr << "\nTime elapsed: " << 1000 * double(clock()) / CLOCKS_PER_SEC << "ms\n"; #endif } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 360 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 360 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 360 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 360 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 2 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 360 KB | Output is correct |
20 | Correct | 3 ms | 340 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 360 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 360 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 360 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 2 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 360 KB | Output is correct |
20 | Correct | 3 ms | 340 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 109 ms | 972 KB | Output is correct |
23 | Correct | 114 ms | 936 KB | Output is correct |
24 | Correct | 136 ms | 940 KB | Output is correct |
25 | Correct | 108 ms | 940 KB | Output is correct |
26 | Correct | 107 ms | 860 KB | Output is correct |
27 | Correct | 144 ms | 860 KB | Output is correct |
28 | Correct | 151 ms | 952 KB | Output is correct |
29 | Correct | 155 ms | 944 KB | Output is correct |
30 | Correct | 152 ms | 984 KB | Output is correct |
31 | Correct | 149 ms | 932 KB | Output is correct |
32 | Correct | 173 ms | 940 KB | Output is correct |
33 | Correct | 176 ms | 944 KB | Output is correct |
34 | Correct | 172 ms | 944 KB | Output is correct |
35 | Correct | 171 ms | 940 KB | Output is correct |
36 | Correct | 180 ms | 880 KB | Output is correct |