답안 #1106738

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1106738 2024-10-31T02:27:19 Z underwaterkillerwhale Nautilus (BOI19_nautilus) C++17
100 / 100
132 ms 159056 KB
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define rep2(i,a,b,c) for (int i=a;i<=b;i+=c)
#define rev(i,a,b) for (int i=a;i>=b;i--)
#define rev2(i,a,b,c) for (int i=a;i>=b;i-=c)
#define ii pair<ll,ll>
#define bit(i,j) ((i>>j)&1)
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define ll long long
#define F first
#define S second
#define sz(a) (ll)(a.size())
#define on(n) __builtin_popcountll(n)
#define ld long double
#define __log2(x) 31-__builtin_clz(x)
#define Mask(x) (1LL<<x)
#define ALL(v) v.begin(),v.end()

const int N=5e3+5;
const int mod=1e9+7;
const int INF=1e9;
const int MAX=1e9;

int n,m,k;
string s;
char a[505][505];
bitset<505> dp[N][505],mask[505];

void solution(){
    cin >> n >> m >> k;
    rep(i,1,n) rep(j,1,m) cin >> a[i][j];
    cin >> s;
    s=' '+s;
    rep(i,1,n) rep(j,1,m)
        if (a[i][j]=='.') dp[0][i].set(j),mask[i].set(j);
    rep(i,1,k)
        rep(row,1,n){
            if (s[i]=='N'||s[i]=='?') dp[i][row]|=dp[i-1][row+1];
            if (s[i]=='S'||s[i]=='?') dp[i][row]|=dp[i-1][row-1];
            if (s[i]=='E'||s[i]=='?') dp[i][row]|=(dp[i-1][row]<<1);
            if (s[i]=='W'||s[i]=='?') dp[i][row]|=(dp[i-1][row]>>1);
            dp[i][row]&=mask[row];
        }
    int res=0;
    rep(row,1,n) res+=dp[k][row].count();
    cout << res;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int test=1;
    //cin >> test;
    while(test--)
        solution();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4688 KB Output is correct
2 Correct 1 ms 4432 KB Output is correct
3 Correct 2 ms 4688 KB Output is correct
4 Correct 2 ms 4688 KB Output is correct
5 Correct 2 ms 4688 KB Output is correct
6 Correct 2 ms 4432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4688 KB Output is correct
2 Correct 1 ms 4432 KB Output is correct
3 Correct 2 ms 4688 KB Output is correct
4 Correct 2 ms 4688 KB Output is correct
5 Correct 2 ms 4688 KB Output is correct
6 Correct 2 ms 4432 KB Output is correct
7 Correct 2 ms 4432 KB Output is correct
8 Correct 1 ms 4688 KB Output is correct
9 Correct 2 ms 4432 KB Output is correct
10 Correct 1 ms 4688 KB Output is correct
11 Correct 2 ms 4688 KB Output is correct
12 Correct 2 ms 4432 KB Output is correct
13 Correct 1 ms 4432 KB Output is correct
14 Correct 1 ms 4432 KB Output is correct
15 Correct 2 ms 4600 KB Output is correct
16 Correct 2 ms 4688 KB Output is correct
17 Correct 2 ms 4580 KB Output is correct
18 Correct 2 ms 4432 KB Output is correct
19 Correct 2 ms 4688 KB Output is correct
20 Correct 2 ms 4880 KB Output is correct
21 Correct 2 ms 4432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4688 KB Output is correct
2 Correct 1 ms 4432 KB Output is correct
3 Correct 2 ms 4688 KB Output is correct
4 Correct 2 ms 4688 KB Output is correct
5 Correct 2 ms 4688 KB Output is correct
6 Correct 2 ms 4432 KB Output is correct
7 Correct 2 ms 4432 KB Output is correct
8 Correct 1 ms 4688 KB Output is correct
9 Correct 2 ms 4432 KB Output is correct
10 Correct 1 ms 4688 KB Output is correct
11 Correct 2 ms 4688 KB Output is correct
12 Correct 2 ms 4432 KB Output is correct
13 Correct 1 ms 4432 KB Output is correct
14 Correct 1 ms 4432 KB Output is correct
15 Correct 2 ms 4600 KB Output is correct
16 Correct 2 ms 4688 KB Output is correct
17 Correct 2 ms 4580 KB Output is correct
18 Correct 2 ms 4432 KB Output is correct
19 Correct 2 ms 4688 KB Output is correct
20 Correct 2 ms 4880 KB Output is correct
21 Correct 2 ms 4432 KB Output is correct
22 Correct 78 ms 158932 KB Output is correct
23 Correct 80 ms 159048 KB Output is correct
24 Correct 81 ms 159048 KB Output is correct
25 Correct 75 ms 159048 KB Output is correct
26 Correct 76 ms 158800 KB Output is correct
27 Correct 102 ms 158872 KB Output is correct
28 Correct 104 ms 159056 KB Output is correct
29 Correct 105 ms 158844 KB Output is correct
30 Correct 104 ms 158792 KB Output is correct
31 Correct 102 ms 158692 KB Output is correct
32 Correct 128 ms 159048 KB Output is correct
33 Correct 126 ms 158792 KB Output is correct
34 Correct 132 ms 159048 KB Output is correct
35 Correct 125 ms 159052 KB Output is correct
36 Correct 126 ms 158776 KB Output is correct