# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314624 | 2020-10-20T13:21:27 Z | Dymo | Nautilus (BOI19_nautilus) | C++14 | 190 ms | 888 KB |
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define pll pair<ll,ll> #define ff first #define ss second #define endl "\n" const ll maxn=5e2+50; const ll mod =1e9+7; const ll base=517; bitset<maxn> a[maxn],dp[maxn][3]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); if (fopen("GIDDY.inp", "r")) { freopen("GIDDY.inp", "r", stdin); freopen("GIDDY.out", "w", stdout) ; } ll n, m, q; cin>>n>>m>>q; for (int i=1; i<=n; i++) { for (int j=0; j<m; j++) { char x; cin>>x ; if (x=='.') a[i][j]=1; else a[i][j]=0; } dp[i][0]=a[i]; } string s; cin>>s; s=" "+s; for (int i=1; i<=q; i++) { for (int t=1; t<=n; t++) { if (s[i]=='N') dp[t][i%2]=dp[t+1][1-i%2]; else if (s[i]=='S') dp[t][i%2]=dp[t-1][1-i%2]; else if (s[i]=='E') dp[t][i%2]=dp[t][1-i%2]<<1; else if (s[i]=='W') dp[t][i%2]=dp[t][1-i%2]>>1; else { dp[t][i%2]=((dp[t][1-i%2]<<1)|(dp[t][1-i%2]>>1)|(dp[t+1][1-i%2])|(dp[t-1][1-i%2])); } dp[t][i%2]&=a[t]; } } ll ans=0; for (int i=1;i<=n;i++) { ans+=dp[i][q%2].count(); } cout <<ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 90 ms | 768 KB | Output is correct |
23 | Correct | 98 ms | 796 KB | Output is correct |
24 | Correct | 85 ms | 768 KB | Output is correct |
25 | Correct | 86 ms | 888 KB | Output is correct |
26 | Correct | 83 ms | 768 KB | Output is correct |
27 | Correct | 143 ms | 768 KB | Output is correct |
28 | Correct | 147 ms | 768 KB | Output is correct |
29 | Correct | 159 ms | 816 KB | Output is correct |
30 | Correct | 144 ms | 768 KB | Output is correct |
31 | Correct | 140 ms | 768 KB | Output is correct |
32 | Correct | 188 ms | 888 KB | Output is correct |
33 | Correct | 186 ms | 800 KB | Output is correct |
34 | Correct | 190 ms | 768 KB | Output is correct |
35 | Correct | 190 ms | 888 KB | Output is correct |
36 | Correct | 187 ms | 768 KB | Output is correct |