답안 #922491

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
922491 2024-02-05T14:49:30 Z vjudge1 Nautilus (BOI19_nautilus) C++17
100 / 100
124 ms 860 KB
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define vl vector<ll>
#define fi first
#define se second
#define in insert
#define mpr make_pair
#define lg(x) __lg(x)
#define bpc(x) __builtin_popcount(x)
#define all(v) v.begin(), v.end()
#define endl "\n"

using namespace std;
const int mod = 998244353;
const long long inf = 1000000000000000000;
const int sz = 505; /// mind the sz
bitset<sz> dp[2][sz], water[sz], x, y;
char a[sz][sz];
ll n, m;
void print(bitset<sz> A){
    for(ll i = 1; i<=m; i++){
        cout << A[i] << ' ';
    }
    cout << endl;
}
void solve(){
    ll i, j, k, c = 1;
    cin>>n>>m>>k;
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            cin>>a[i][j];
            if(a[i][j] == '.'){
                dp[0][i].set(j, 1);
                water[i].set(j, 1);
            }
        }
    }
    string s;
    cin >> s;
    s = "*" + s;
    for(i=1;i<=k;i++){
        for(j=1;j<=n;j++){
            dp[c][j] = x;
            if((s[i] == 'N' || s[i] == '?') && j < n){
                dp[c][j] |= dp[c ^ 1][j + 1];
            }
            if((s[i] == 'S' || s[i] == '?') && j > 1){
                dp[c][j] |= dp[c ^ 1][j - 1];
            }
            if(s[i] == 'W' || s[i] == '?'){
                dp[c][j] |= (dp[c ^ 1][j] >> 1);
            }
            if(s[i] == 'E' || s[i] == '?'){
                dp[c][j] |= (dp[c ^ 1][j] << 1);
            }
//            print(dp[c][j]);
//            print(water[j]);
            dp[c][j] &= water[j];
//            print(dp[c][j]);
        }
        c ^= 1;
//        break;
    }
    ll cnt = 0;
    for(i=1;i<=n;i++){
        //cout << i << " -> ";
        for(j=1;j<=m;j++){
            if(dp[k % 2][i][j]){
                //cout << j << ' ';
                cnt++;
            }
        }
        //cout << endl;
    }
    cout << cnt << endl;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll tst=1;
    //cin>>tst;             //MIND THIS
    while(tst--){
        solve();
    }
}
/*
1
6
4 1 6 3 10 7
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 63 ms 600 KB Output is correct
23 Correct 66 ms 600 KB Output is correct
24 Correct 65 ms 600 KB Output is correct
25 Correct 64 ms 856 KB Output is correct
26 Correct 64 ms 600 KB Output is correct
27 Correct 92 ms 604 KB Output is correct
28 Correct 94 ms 796 KB Output is correct
29 Correct 93 ms 792 KB Output is correct
30 Correct 94 ms 600 KB Output is correct
31 Correct 103 ms 776 KB Output is correct
32 Correct 116 ms 796 KB Output is correct
33 Correct 124 ms 604 KB Output is correct
34 Correct 114 ms 796 KB Output is correct
35 Correct 116 ms 860 KB Output is correct
36 Correct 114 ms 780 KB Output is correct