답안 #925932

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925932 2024-02-12T11:02:43 Z vjudge1 Nautilus (BOI19_nautilus) C++17
100 / 100
51 ms 1060 KB
/*
no more temmy :(
*/

#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
// #include<icecream.hpp>
// using namespace icecream;
#define ll long long
#define int ll
#define ld long double
#define y1 cheza
// mt19937 rng(1983413);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const int N=510;
const int M=1e6;
const int B=317;
const int mod=998244353;
const int INF=1e18;
const int lg=64;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
const double eps=1e-9;
int n,m,k;
char a[N][N];
int rv[N];
string s;
bool check(int x,int y){
    if(x<1||y<1||x>n||y>m||a[x][y]=='#')return 0;
    return 1;
}
bitset<N>q[N],q2[N];
bitset<N>g[N];
void test(){
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
            if(a[i][j]=='.'){
                g[i][j]=1;
            }
            else{
                g[i][j]=0;
            }
        }
    }
    cin>>s;
  
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]=='.'){
                q[i][j]=1;
            }
        }   
    }
    for(int j=0;j<k;j++){
        if(s[j]=='?'){
            for(int i=1;i<=n;i++){
                q2[i]=(q[i]<<1ll)|(q[i]>>1ll);
            }
            for(int i=1;i<n;i++){
                q2[i]|=q[i+1];
            }
            for(int i=n;i>=2;i--){
                q2[i]|=q[i-1];
            }
            swap(q,q2);
        }
        else{
            if(s[j]=='N'){
                for(int i=1;i<n;i++){
                    swap(q[i],q[i+1]);
                }
                q[n].reset();
            }
            if(s[j]=='S'){
                for(int i=n;i>=2;i--){
                    swap(q[i],q[i-1]);
                }
                q[1].reset();
            }
            if(s[j]=='W'){
                for(int i=1;i<=n;i++){
                    q[i]>>=1ll;
                }
            }
            if(s[j]=='E'){
                for(int i=1;i<=n;i++){
                    q[i]<<=1ll;
                }
            }
        }
        for(int i=1;i<=n;i++){
            q[i]&=g[i];
        }
    }
    int res=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(q[i][j]){
                // cout<<i<<' '<<j<<'\n';
                res++;
            }
        }
    }   
    cout<<res<<'\n';

}
/*

*/  
 
signed main(){
    rv['N']=1;
    rv['S']=0;
    rv['W']=3;
    rv['E']=2;
    // ic.prefix("debug->| ");
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    long long t2=1;
    //  cin>>t2;
    for(int i=1;i<=t2;i++){
        test();
    }
    
    return 0;
 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 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 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 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 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 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 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 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 348 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 348 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 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 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 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 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 348 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 26 ms 604 KB Output is correct
23 Correct 28 ms 860 KB Output is correct
24 Correct 27 ms 856 KB Output is correct
25 Correct 26 ms 860 KB Output is correct
26 Correct 25 ms 1000 KB Output is correct
27 Correct 37 ms 856 KB Output is correct
28 Correct 39 ms 856 KB Output is correct
29 Correct 40 ms 856 KB Output is correct
30 Correct 39 ms 856 KB Output is correct
31 Correct 37 ms 860 KB Output is correct
32 Correct 48 ms 860 KB Output is correct
33 Correct 48 ms 1060 KB Output is correct
34 Correct 50 ms 856 KB Output is correct
35 Correct 51 ms 860 KB Output is correct
36 Correct 47 ms 856 KB Output is correct