# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
377656 | 2021-03-14T15:42:16 Z | cpp219 | Nautilus (BOI19_nautilus) | C++14 | 330 ms | 179308 KB |
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include<bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; typedef pair<ll,ll> LL; const ll N = 500 + 9; const ll inf = 1e16 + 7; char a[N][N]; ll n,m,sz; string s; bitset<520> dp[N][5200],sea[N],x; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "test" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } cin>>n>>m>>sz; for (ll i = 1;i <= n;i++) for (ll j = 1;j <= m;j++){ cin>>a[i][j]; if (a[i][j] == '.') sea[i][j] = dp[i][0][j] = 1; else sea[i][j] = dp[i][0][j] = 0; } cin>>s; s = " " + s; for (ll t = 1;t <= sz;t++){ for (ll i = 1;i <= n;i++){ if (s[t] == 'N') dp[i][t] = (dp[i + 1][t - 1]); if (s[t] == 'S') dp[i][t] = (dp[i - 1][t - 1]); if (s[t] == 'E') dp[i][t] = ((dp[i][t - 1] << 1)); if (s[t] == 'W') dp[i][t] = ((dp[i][t - 1] >> 1)); if (s[t] == '?') dp[i][t] = ((dp[i][t - 1] << 1)|(dp[i][t - 1] >> 1)|(dp[i + 1][t - 1])|(dp[i - 1][t - 1])); dp[i][t] &= sea[i]; dp[i][t] &= sea[i]; //for (ll j = 1;j <= m;j++) cout<<dp[i][t][j]; exit(0); } } ll ans = 0; for (ll i = 1;i <= n;i++){ for (ll j = 1;j <= m;j++){ if (dp[i][sz][j]) ans++; //cout<<dp[i][sz][j]; } //cout<<"\n"; } cout<<ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1644 KB | Output is correct |
2 | Correct | 2 ms | 1644 KB | Output is correct |
3 | Correct | 2 ms | 1644 KB | Output is correct |
4 | Correct | 2 ms | 1644 KB | Output is correct |
5 | Correct | 2 ms | 1644 KB | Output is correct |
6 | Correct | 2 ms | 1644 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1644 KB | Output is correct |
2 | Correct | 2 ms | 1644 KB | Output is correct |
3 | Correct | 2 ms | 1644 KB | Output is correct |
4 | Correct | 2 ms | 1644 KB | Output is correct |
5 | Correct | 2 ms | 1644 KB | Output is correct |
6 | Correct | 2 ms | 1644 KB | Output is correct |
7 | Correct | 2 ms | 1644 KB | Output is correct |
8 | Correct | 87 ms | 1644 KB | Output is correct |
9 | Correct | 2 ms | 1644 KB | Output is correct |
10 | Correct | 2 ms | 1644 KB | Output is correct |
11 | Correct | 2 ms | 1644 KB | Output is correct |
12 | Correct | 85 ms | 1644 KB | Output is correct |
13 | Correct | 84 ms | 1644 KB | Output is correct |
14 | Correct | 139 ms | 1516 KB | Output is correct |
15 | Correct | 2 ms | 1644 KB | Output is correct |
16 | Correct | 2 ms | 1644 KB | Output is correct |
17 | Correct | 2 ms | 1644 KB | Output is correct |
18 | Correct | 2 ms | 1644 KB | Output is correct |
19 | Correct | 2 ms | 1644 KB | Output is correct |
20 | Correct | 2 ms | 1644 KB | Output is correct |
21 | Correct | 2 ms | 1644 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1644 KB | Output is correct |
2 | Correct | 2 ms | 1644 KB | Output is correct |
3 | Correct | 2 ms | 1644 KB | Output is correct |
4 | Correct | 2 ms | 1644 KB | Output is correct |
5 | Correct | 2 ms | 1644 KB | Output is correct |
6 | Correct | 2 ms | 1644 KB | Output is correct |
7 | Correct | 2 ms | 1644 KB | Output is correct |
8 | Correct | 87 ms | 1644 KB | Output is correct |
9 | Correct | 2 ms | 1644 KB | Output is correct |
10 | Correct | 2 ms | 1644 KB | Output is correct |
11 | Correct | 2 ms | 1644 KB | Output is correct |
12 | Correct | 85 ms | 1644 KB | Output is correct |
13 | Correct | 84 ms | 1644 KB | Output is correct |
14 | Correct | 139 ms | 1516 KB | Output is correct |
15 | Correct | 2 ms | 1644 KB | Output is correct |
16 | Correct | 2 ms | 1644 KB | Output is correct |
17 | Correct | 2 ms | 1644 KB | Output is correct |
18 | Correct | 2 ms | 1644 KB | Output is correct |
19 | Correct | 2 ms | 1644 KB | Output is correct |
20 | Correct | 2 ms | 1644 KB | Output is correct |
21 | Correct | 2 ms | 1644 KB | Output is correct |
22 | Correct | 228 ms | 179020 KB | Output is correct |
23 | Correct | 226 ms | 179052 KB | Output is correct |
24 | Correct | 226 ms | 179052 KB | Output is correct |
25 | Correct | 245 ms | 179052 KB | Output is correct |
26 | Correct | 230 ms | 179052 KB | Output is correct |
27 | Correct | 308 ms | 179084 KB | Output is correct |
28 | Correct | 287 ms | 179052 KB | Output is correct |
29 | Correct | 290 ms | 179012 KB | Output is correct |
30 | Correct | 284 ms | 179052 KB | Output is correct |
31 | Correct | 305 ms | 179180 KB | Output is correct |
32 | Correct | 327 ms | 179052 KB | Output is correct |
33 | Correct | 328 ms | 179180 KB | Output is correct |
34 | Correct | 330 ms | 179052 KB | Output is correct |
35 | Correct | 324 ms | 179052 KB | Output is correct |
36 | Correct | 328 ms | 179308 KB | Output is correct |