답안 #957810

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
957810 2024-04-04T11:06:02 Z batsukh2006 Nautilus (BOI19_nautilus) C++17
100 / 100
175 ms 1036 KB
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>
#include<utility>
#include<set>
#include<cmath>
#include<queue>
#include<deque>
#include<functional>
#include<stack>
#include<limits.h>
#include<iomanip>
#include<unordered_map> 
#include<numeric>
#include<tuple>
#include<bitset>
using namespace std;
 
#define MOD 1000000007
#define int long long
#define ss second
#define ff first
#define endl '\n'
typedef pair<int,int> pp;
signed main(){
    // freopen("file.in", "r", stdin);
    // freopen("file.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int r,c,m; cin>>r>>c>>m;
    bitset<500> a[500],dp[500],e;
    for(int i=0; i<r; i++){
    	for(int j=0; j<c; j++){
    		char c; cin>>c;
    		if(c=='#'){
				a[i][j]=0;
			}else{
    			a[i][j]=1;
    			dp[i][j]=1;
    		}
    	}
    }
    string s; cin>>s;
    for(int k=0; k<m; k++){
    	if(s[k]=='W'){
    		for(int i=0; i<r; i++){
    			dp[i]=(a[i]&(dp[i]>>1));
    		}
    	}else if(s[k]=='N'){
    		for(int i=0; i<r-1; i++){
    			dp[i]=(a[i]&dp[i+1]);
    		}
    		dp[r-1]=e;
    	}else if(s[k]=='E'){
    		for(int i=0; i<r; i++){
    			dp[i]=(a[i]&(dp[i]<<1));
    		}
    	}else if(s[k]=='S'){
    		for(int i=r-1; i>0; i--){
    			dp[i]=(a[i]&dp[i-1]);
    		}
    		dp[0]=e;
    	}else{
    		bitset<500> tmp[500];
    		for(int i=0; i<r; i++){
    			tmp[i]|=(a[i]&(dp[i]>>1));
    		}
    		for(int i=0; i<r-1; i++){
    			tmp[i]|=(a[i]&dp[i+1]);
    		}
    		for(int i=0; i<r; i++){
    			tmp[i]|=(a[i]&(dp[i]<<1));
    		}
    		for(int i=r-1; i>0; i--){
    			tmp[i]|=(a[i]&dp[i-1]);
    		}
    		for(int i=0; i<r; i++){
    			dp[i]=tmp[i];
    		}
    	}
    }
    int ans=0;
    for(int i=0; i<r; i++){
    	for(int j=0; j<c; j++){
    		if(dp[i][j]==1) ans++;
    	}
    }
    cout<<ans;
    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 348 KB Output is correct
5 Correct 1 ms 500 KB Output is correct
6 Correct 1 ms 552 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 348 KB Output is correct
5 Correct 1 ms 500 KB Output is correct
6 Correct 1 ms 552 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 556 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 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 344 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 424 KB Output is correct
21 Correct 1 ms 344 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 348 KB Output is correct
5 Correct 1 ms 500 KB Output is correct
6 Correct 1 ms 552 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 556 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 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 344 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 424 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 81 ms 604 KB Output is correct
23 Correct 84 ms 788 KB Output is correct
24 Correct 79 ms 600 KB Output is correct
25 Correct 78 ms 784 KB Output is correct
26 Correct 77 ms 856 KB Output is correct
27 Correct 130 ms 844 KB Output is correct
28 Correct 121 ms 604 KB Output is correct
29 Correct 121 ms 1036 KB Output is correct
30 Correct 131 ms 784 KB Output is correct
31 Correct 125 ms 784 KB Output is correct
32 Correct 163 ms 788 KB Output is correct
33 Correct 153 ms 780 KB Output is correct
34 Correct 175 ms 788 KB Output is correct
35 Correct 154 ms 600 KB Output is correct
36 Correct 160 ms 784 KB Output is correct