Submission #661313

# Submission time Handle Problem Language Result Execution time Memory
661313 2022-11-25T13:20:02 Z jiahng Nautilus (BOI19_nautilus) C++14
66 / 100
1000 ms 1208 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][2];
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][1] = (dp[i][j-1][0] & A[i][j]);
            }else if (S[t] == 'W'){
                dp[i][j][1] = (dp[i][j+1][0] & A[i][j]);
            }else if (S[t] == 'S') dp[i][j][1] = (dp[i-1][j][0] & A[i][j]);
            else if (S[t] == 'N') dp[i][j][1] = (dp[i+1][j][0] & A[i][j]);
            else{
                dp[i][j][1] = ((dp[i-1][j][0] | dp[i+1][j][0] | dp[i][j-1][0] | dp[i][j+1][0]) & A[i][j]);
            }
        }
        FOR(i,1,R) FOR(j,1,C) dp[i][j][0] = dp[i][j][1];
    }
    int ans = 0;
    FOR(i,1,R) FOR(j,1,C) ans += dp[i][j][0];
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 4 ms 468 KB Output is correct
3 Correct 3 ms 468 KB Output is correct
4 Correct 3 ms 444 KB Output is correct
5 Correct 3 ms 468 KB Output is correct
6 Correct 4 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 4 ms 468 KB Output is correct
3 Correct 3 ms 468 KB Output is correct
4 Correct 3 ms 444 KB Output is correct
5 Correct 3 ms 468 KB Output is correct
6 Correct 4 ms 468 KB Output is correct
7 Correct 4 ms 468 KB Output is correct
8 Correct 3 ms 444 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 3 ms 468 KB Output is correct
11 Correct 3 ms 468 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 4 ms 468 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 4 ms 468 KB Output is correct
16 Correct 3 ms 468 KB Output is correct
17 Correct 3 ms 468 KB Output is correct
18 Correct 3 ms 468 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 3 ms 468 KB Output is correct
21 Correct 4 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 4 ms 468 KB Output is correct
3 Correct 3 ms 468 KB Output is correct
4 Correct 3 ms 444 KB Output is correct
5 Correct 3 ms 468 KB Output is correct
6 Correct 4 ms 468 KB Output is correct
7 Correct 4 ms 468 KB Output is correct
8 Correct 3 ms 444 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 3 ms 468 KB Output is correct
11 Correct 3 ms 468 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 4 ms 468 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 4 ms 468 KB Output is correct
16 Correct 3 ms 468 KB Output is correct
17 Correct 3 ms 468 KB Output is correct
18 Correct 3 ms 468 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 3 ms 468 KB Output is correct
21 Correct 4 ms 468 KB Output is correct
22 Execution timed out 1087 ms 1208 KB Time limit exceeded
23 Halted 0 ms 0 KB -