답안 #639601

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
639601 2022-09-10T17:28:12 Z erto Nautilus (BOI19_nautilus) C++17
100 / 100
147 ms 676 KB
#include <bits/stdc++.h>
typedef long long int ll;
#define INF ll(1e9 + 7)
#define INF2 998244353
#define N (ll)(1e5 + 5)
using namespace std;
#define int ll
#define lsb(x) (x & (-x))
 
int r, c, m, g, h; 
string s;
bitset<502> a[502], pos[502], t[502];
bitset<502> t1, t2;

 
int d1[] = {0, 0, 1, -1}, d2[] = {1, - 1, 0, 0};



void solve(){
    cin >> r >> c >> m;
    for(int i=1; i<=r; i++){
        cin >> s;
        for(int j=1; j<=c; j++){
            a[i][j] = s[j - 1] == '.';
            pos[i][j] = a[i][j];
        }
    }
    cin >> s;

    for(int i=0; i<m; i++){
        if(s[i] == '?'){
            for(int n=1; n<=r; n++){
                t1 = a[n] >> 1;
                t2 = a[n] << 1;
                t[n] |= t1;
                t[n] |= t2;
            }
            for(int n=1; n<r; n++){
                t[n] |= a[n + 1];
                t[n + 1] |= a[n];
            }
            for(int i=1; i<=r; i++){
                a[i] = t[i] & pos[i];
                t[i] &= 0;
            }
        }
        else if(s[i] == 'W'){
            for(int n=1; n<=r; n++){
                a[n] = a[n] >> 1;
                a[n] &= pos[n];
            }
        }
        else if(s[i] == 'E'){
            for(int n=1; n<=r; n++){
                a[n] = a[n] << 1;
                a[n] &= pos[n];
            }
        }
        else if(s[i] == 'S'){
            for(int n=r; n; n--){
                a[n] |= a[n - 1];
                a[n] &= a[n - 1];
                a[n] &= pos[n];
            }
        }
        else{
            for(int n=1; n<=r; n++){
                a[n] |= a[n + 1];
                a[n] &= a[n + 1];
                a[n] &= pos[n];
            }
        }
       
    }
    int sum = 0;
    for(int n=r; n; n--){
        for(int l=1; l<=c; l++){
            sum += a[n][l];
        }
    }
    cout << sum;
}
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int T = 1;
    //cin>>T;
    while (T--){
        solve();
    }
}
# 결과 실행 시간 메모리 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 324 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 336 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 324 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 63 ms 588 KB Output is correct
23 Correct 64 ms 656 KB Output is correct
24 Correct 72 ms 596 KB Output is correct
25 Correct 61 ms 660 KB Output is correct
26 Correct 64 ms 592 KB Output is correct
27 Correct 93 ms 660 KB Output is correct
28 Correct 99 ms 660 KB Output is correct
29 Correct 90 ms 660 KB Output is correct
30 Correct 94 ms 676 KB Output is correct
31 Correct 92 ms 596 KB Output is correct
32 Correct 117 ms 656 KB Output is correct
33 Correct 117 ms 660 KB Output is correct
34 Correct 147 ms 656 KB Output is correct
35 Correct 125 ms 596 KB Output is correct
36 Correct 116 ms 656 KB Output is correct