# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
661311 |
2022-11-25T13:18:04 Z |
jiahng |
Nautilus (BOI19_nautilus) |
C++14 |
|
113 ms |
262144 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ll int
typedef pair<int,int> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 505
#define maxt 5005
#define INF (ll)1e18
#define MOD 1000000007
typedef pair <vi, int> pvi;
typedef pair <int,pi> ipi;
typedef vector <pii> vpii;
int R,C,M;
bool A[maxn][maxn];
char S[maxt], ch;
bool dp[maxn][maxn][maxt];
int32_t main(){
cin >> R >> C >> M;
FOR(i,1,R) FOR(j,1,C){
cin >> ch; A[i][j] = (ch == '.');
}
FOR(i,1,M) cin >> S[i];
FOR(i,1,R) FOR(j,1,C){
dp[i][j][0] = A[i][j];
}
FOR(t,1,M){
FOR(i,1,R) FOR(j,1,C){
if (S[t] == 'E'){
dp[i][j][t] = (dp[i][j-1][t-1] & A[i][j]);
}else if (S[t] == 'W'){
dp[i][j][t] = (dp[i][j+1][t-1] & A[i][j]);
}else if (S[t] == 'S') dp[i][j][t] = (dp[i-1][j][t-1] & A[i][j]);
else if (S[t] == 'N') dp[i][j][t] = (dp[i+1][j][t-1] & A[i][j]);
else{
dp[i][j][t] = ((dp[i-1][j][t-1] | dp[i+1][j][t-1] | dp[i][j-1][t-1] | dp[i][j+1][t-1]) & A[i][j]);
}
}
}
int ans = 0;
FOR(i,1,R) FOR(j,1,C) ans += dp[i][j][M];
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
41804 KB |
Output is correct |
2 |
Correct |
23 ms |
41792 KB |
Output is correct |
3 |
Correct |
24 ms |
41840 KB |
Output is correct |
4 |
Correct |
24 ms |
41824 KB |
Output is correct |
5 |
Correct |
24 ms |
41940 KB |
Output is correct |
6 |
Correct |
26 ms |
41828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
41804 KB |
Output is correct |
2 |
Correct |
23 ms |
41792 KB |
Output is correct |
3 |
Correct |
24 ms |
41840 KB |
Output is correct |
4 |
Correct |
24 ms |
41824 KB |
Output is correct |
5 |
Correct |
24 ms |
41940 KB |
Output is correct |
6 |
Correct |
26 ms |
41828 KB |
Output is correct |
7 |
Correct |
25 ms |
41740 KB |
Output is correct |
8 |
Correct |
23 ms |
41752 KB |
Output is correct |
9 |
Correct |
24 ms |
41824 KB |
Output is correct |
10 |
Correct |
24 ms |
41768 KB |
Output is correct |
11 |
Correct |
23 ms |
41772 KB |
Output is correct |
12 |
Correct |
24 ms |
41744 KB |
Output is correct |
13 |
Correct |
25 ms |
41784 KB |
Output is correct |
14 |
Correct |
24 ms |
41740 KB |
Output is correct |
15 |
Correct |
26 ms |
41776 KB |
Output is correct |
16 |
Correct |
27 ms |
41776 KB |
Output is correct |
17 |
Correct |
27 ms |
41788 KB |
Output is correct |
18 |
Correct |
27 ms |
41772 KB |
Output is correct |
19 |
Correct |
28 ms |
41756 KB |
Output is correct |
20 |
Correct |
25 ms |
41784 KB |
Output is correct |
21 |
Correct |
26 ms |
41740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
41804 KB |
Output is correct |
2 |
Correct |
23 ms |
41792 KB |
Output is correct |
3 |
Correct |
24 ms |
41840 KB |
Output is correct |
4 |
Correct |
24 ms |
41824 KB |
Output is correct |
5 |
Correct |
24 ms |
41940 KB |
Output is correct |
6 |
Correct |
26 ms |
41828 KB |
Output is correct |
7 |
Correct |
25 ms |
41740 KB |
Output is correct |
8 |
Correct |
23 ms |
41752 KB |
Output is correct |
9 |
Correct |
24 ms |
41824 KB |
Output is correct |
10 |
Correct |
24 ms |
41768 KB |
Output is correct |
11 |
Correct |
23 ms |
41772 KB |
Output is correct |
12 |
Correct |
24 ms |
41744 KB |
Output is correct |
13 |
Correct |
25 ms |
41784 KB |
Output is correct |
14 |
Correct |
24 ms |
41740 KB |
Output is correct |
15 |
Correct |
26 ms |
41776 KB |
Output is correct |
16 |
Correct |
27 ms |
41776 KB |
Output is correct |
17 |
Correct |
27 ms |
41788 KB |
Output is correct |
18 |
Correct |
27 ms |
41772 KB |
Output is correct |
19 |
Correct |
28 ms |
41756 KB |
Output is correct |
20 |
Correct |
25 ms |
41784 KB |
Output is correct |
21 |
Correct |
26 ms |
41740 KB |
Output is correct |
22 |
Runtime error |
113 ms |
262144 KB |
Execution killed with signal 9 |
23 |
Halted |
0 ms |
0 KB |
- |