답안 #958189

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
958189 2024-04-05T06:07:34 Z ezzzay Nautilus (BOI19_nautilus) C++14
66 / 100
1000 ms 604 KB
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define int long long
#define ss second
#define pb push_back
const int N=5e3+5;
const int NM=501;
char arr[NM][NM];
bitset<NM> dp[NM];
bitset<NM>rck[NM];
signed main(){
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>arr[i][j];
        }
    }
    string s;
    cin>>s;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(arr[i][j]=='#'){
                rck[i][j]=0;
                continue;
            }
            rck[i][j]=1;
            dp[i][j]=1;
            
        }
    }
    for(int l=0;l<k;l++){
        bitset<NM>tmp[NM];
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                tmp[i][j]=dp[i][j];
                dp[i][j]=0;
            }
        }
        
        if(s[l]=='E'){
            for(int i=1;i<=n;i++){
                dp[i]|=(tmp[i]<<1);
                dp[i]&=rck[i];
            }  
        }
        else if(s[l]=='W'){
            for(int i=1;i<=n;i++){
                dp[i]|=(tmp[i]>>1);
                dp[i]&=rck[i];
            }  
        }
        else if(s[l]=='N'){
            for(int i=1;i<=m;i++){
                dp[i-1]|=tmp[i];
                dp[i-1]&=rck[i-1];
            }  
        }
        else if(s[l]=='S'){
            for(int i=1;i<=m;i++){
                dp[i+1]|=tmp[i];
                dp[i+1]&=rck[i+1];
            }  
        }
        else{
            for(int i=1;i<=n;i++){
                dp[i]|=(tmp[i]<<1);
                dp[i]&=rck[i];
            }  
            for(int i=1;i<=n;i++){
                dp[i]|=(tmp[i]>>1);
                dp[i]&=rck[i];
            }  
            for(int i=1;i<=m;i++){
                dp[i-1]|=tmp[i];
                dp[i-1]&=rck[i-1];
            } 
             for(int i=1;i<=m;i++){
                dp[i+1]|=tmp[i];
                dp[i+1]&=rck[i+1];
            }  
        }
        
    }
    
    int cnt=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cnt+= dp[i][j];
        }
    }
    cout<<cnt;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 348 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 348 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
12 Correct 4 ms 532 KB Output is correct
13 Correct 4 ms 348 KB Output is correct
14 Correct 4 ms 348 KB Output is correct
15 Correct 4 ms 344 KB Output is correct
16 Correct 4 ms 344 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 4 ms 348 KB Output is correct
19 Correct 4 ms 528 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 4 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 348 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
12 Correct 4 ms 532 KB Output is correct
13 Correct 4 ms 348 KB Output is correct
14 Correct 4 ms 348 KB Output is correct
15 Correct 4 ms 344 KB Output is correct
16 Correct 4 ms 344 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 4 ms 348 KB Output is correct
19 Correct 4 ms 528 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 4 ms 348 KB Output is correct
22 Execution timed out 1048 ms 604 KB Time limit exceeded
23 Halted 0 ms 0 KB -