답안 #661317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
661317 2022-11-25T13:29:43 Z jiahng Nautilus (BOI19_nautilus) C++14
100 / 100
191 ms 972 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;
bitset <maxn> dp[maxn][2];
bitset <maxn> freebs[maxn];
int32_t main(){
    cin >> R >> C >> M;
    FOR(i,1,R){
        FOR(j,1,C){
            cin >> ch; A[i][j] = (ch == '.');
            freebs[i][j] = A[i][j];
        }
    }
    FOR(i,1,M) cin >> S[i];

    FOR(i,1,R){
        FOR(j,1,C) dp[i][0][j] = A[i][j]; 
    }
    FOR(t,1,M){
        FOR(i,1,R){ 
            if (S[t] == 'E'){
                // dp[i][j][1] = (dp[i][j-1][0] & A[i][j]);
                dp[i][1] = ((dp[i][0] << 1) & freebs[i]);
            }else if (S[t] == 'W'){
                //dp[i][j][1] = (dp[i][j+1][0] & A[i][j]);
                dp[i][1] = ((dp[i][0] >> 1) & freebs[i]);
            }else if (S[t] == 'S'){
                //dp[i][j][1] = (dp[i-1][j][0] & A[i][j]);
                dp[i][1] = (dp[i-1][0] & freebs[i]);
            }else if (S[t] == 'N'){
                //dp[i][j][1] = (dp[i+1][j][0] & A[i][j]);
                dp[i][1] = (dp[i+1][0] & freebs[i]);
            }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]);
                dp[i][1] = (((dp[i][0] >> 1) | (dp[i][0] << 1) | dp[i+1][0] | dp[i-1][0]) & freebs[i]);
            }
        }
        FOR(i,1,R) dp[i][0] = dp[i][1];
    }
    int ans = 0;
    FOR(i,1,R) ans += dp[i][0].count();
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 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 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 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 340 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 332 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 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 340 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 340 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 332 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 93 ms 636 KB Output is correct
23 Correct 97 ms 880 KB Output is correct
24 Correct 96 ms 872 KB Output is correct
25 Correct 91 ms 876 KB Output is correct
26 Correct 95 ms 972 KB Output is correct
27 Correct 145 ms 852 KB Output is correct
28 Correct 147 ms 884 KB Output is correct
29 Correct 150 ms 880 KB Output is correct
30 Correct 152 ms 896 KB Output is correct
31 Correct 144 ms 780 KB Output is correct
32 Correct 187 ms 852 KB Output is correct
33 Correct 191 ms 880 KB Output is correct
34 Correct 188 ms 852 KB Output is correct
35 Correct 188 ms 852 KB Output is correct
36 Correct 187 ms 972 KB Output is correct