답안 #897982

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
897982 2024-01-04T06:44:24 Z LCJLY Nautilus (BOI19_nautilus) C++14
100 / 100
548 ms 2136 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << "  " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << "  " << j << " " << #i << "  " << q << " " << #p << endl; 
#define show4(x,y) for(auto it:x) cout << it << " "; cout << #y << endl;
typedef pair<int,int>pii;
typedef pair<pii,pii>pi2;

//int n,m,k;
//string arr[105];
//vector<pii>dir[105];
//int memo[105][105][105];

//int dp(int index, int pos, int pos2){
	//if(index==k) return 1;
	//if(memo[index][pos][pos2]!=-1) return memo[index][pos][pos2];
	//int ans=0;
	
	//for(auto it:dir[index]){
		//int newx=pos+it.first;
		//int newy=pos2+it.second;
		//if(newx<0||newy<0||newx>=n||newy>=m) continue;
		//if(arr[newx][newy]=='#') continue;
		//ans|=dp(index+1,newx,newy);
	//}
	////show3(index,index,pos,pos,pos2,pos2);
	////show(ans,ans);
	//return memo[index][pos][pos2]=ans;
//}

void solve(){	
	//cin >> n >> m >> k;
	
	//for(int x=0;x<n;x++){
		//cin >> arr[x];
	//}
	
	
	//string s;
	//cin >> s;
	
	//reverse(s.begin(),s.end());
	//for(int x=0;x<k;x++){
		//if(s[x]=='N'){
			//dir[x].push_back({1,0});
		//}
		//else if(s[x]=='S'){
			//dir[x].push_back({-1,0});
		//}
		//else if(s[x]=='W'){
			//dir[x].push_back({0,1});
		//}
		//else if(s[x]=='E'){
			//dir[x].push_back({0,-1});
		//}
		//else{
			//dir[x].push_back({1,0});
			//dir[x].push_back({-1,0});
			//dir[x].push_back({0,1});
			//dir[x].push_back({0,-1});
		//}
	//}
	
	//memset(memo,-1,sizeof(memo));
	//int counter=0;
	//for(int x=0;x<n;x++){
		//for(int y=0;y<m;y++){
			//if(arr[x][y]=='#') continue;
			//int add=dp(0,x,y);
			////show3(x,x,y,y,add,add);
			//counter+=add;
		//}
	//}
	//cout << counter;
	
	int n,m,k;
	cin >> n >> m >> k;
	
	string arr[n];
	for(int x=0;x<n;x++){
		cin >> arr[x];
	}
	
	string s;
	cin >> s;
	
	bitset<1005000>bs;
	bitset<1005000>check;
	
	int offset=1001;
	for(int x=0;x<n;x++){
		for(int y=0;y<m;y++){
			if(arr[x][y]=='.'){
				check[x*offset+y]=1;
			}
		}
	}
	
	//cout << check.count() << " check\n";
	
	bs|=check;
	
	for(int x=0;x<k;x++){
		if(s[x]=='N'){
			bs>>=offset;
		}
		else if(s[x]=='S'){
			bs<<=offset;
		}
		else if(s[x]=='E'){
			bs<<=1;
		}
		else if(s[x]=='W'){
			bs>>=1;
		}
		else{
			bs=((bs>>offset)|(bs<<offset)|(bs<<1)|(bs>>1));
		}
		bs&=check;
	}
	
	int counter=0;
	for(int x=0;x<n;x++){
		for(int y=0;y<m;y++){
			if(bs[x*offset+y]==1) counter++;
		}
	}
	
	cout << counter;
}
 
int32_t main(){										
	ios::sync_with_stdio(0);	
	cin.tie(0);
	//freopen("redistricting.in", "r", stdin);
	//freopen("redistricting.out", "w", stdout);
	int t=1;
	//cin >> t;
	while(t--){
		solve();
	}	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1372 KB Output is correct
2 Correct 3 ms 1372 KB Output is correct
3 Correct 6 ms 1372 KB Output is correct
4 Correct 3 ms 1372 KB Output is correct
5 Correct 3 ms 1372 KB Output is correct
6 Correct 3 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1372 KB Output is correct
2 Correct 3 ms 1372 KB Output is correct
3 Correct 6 ms 1372 KB Output is correct
4 Correct 3 ms 1372 KB Output is correct
5 Correct 3 ms 1372 KB Output is correct
6 Correct 3 ms 1372 KB Output is correct
7 Correct 7 ms 1368 KB Output is correct
8 Correct 6 ms 1372 KB Output is correct
9 Correct 7 ms 1372 KB Output is correct
10 Correct 7 ms 1372 KB Output is correct
11 Correct 6 ms 1372 KB Output is correct
12 Correct 9 ms 1568 KB Output is correct
13 Correct 9 ms 1368 KB Output is correct
14 Correct 9 ms 1368 KB Output is correct
15 Correct 9 ms 1572 KB Output is correct
16 Correct 9 ms 1372 KB Output is correct
17 Correct 12 ms 1372 KB Output is correct
18 Correct 12 ms 1372 KB Output is correct
19 Correct 12 ms 1372 KB Output is correct
20 Correct 12 ms 1372 KB Output is correct
21 Correct 14 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1372 KB Output is correct
2 Correct 3 ms 1372 KB Output is correct
3 Correct 6 ms 1372 KB Output is correct
4 Correct 3 ms 1372 KB Output is correct
5 Correct 3 ms 1372 KB Output is correct
6 Correct 3 ms 1372 KB Output is correct
7 Correct 7 ms 1368 KB Output is correct
8 Correct 6 ms 1372 KB Output is correct
9 Correct 7 ms 1372 KB Output is correct
10 Correct 7 ms 1372 KB Output is correct
11 Correct 6 ms 1372 KB Output is correct
12 Correct 9 ms 1568 KB Output is correct
13 Correct 9 ms 1368 KB Output is correct
14 Correct 9 ms 1368 KB Output is correct
15 Correct 9 ms 1572 KB Output is correct
16 Correct 9 ms 1372 KB Output is correct
17 Correct 12 ms 1372 KB Output is correct
18 Correct 12 ms 1372 KB Output is correct
19 Correct 12 ms 1372 KB Output is correct
20 Correct 12 ms 1372 KB Output is correct
21 Correct 14 ms 1368 KB Output is correct
22 Correct 235 ms 1828 KB Output is correct
23 Correct 259 ms 2128 KB Output is correct
24 Correct 229 ms 1884 KB Output is correct
25 Correct 231 ms 1880 KB Output is correct
26 Correct 235 ms 2064 KB Output is correct
27 Correct 409 ms 2072 KB Output is correct
28 Correct 417 ms 2076 KB Output is correct
29 Correct 399 ms 2068 KB Output is correct
30 Correct 419 ms 2068 KB Output is correct
31 Correct 391 ms 2068 KB Output is correct
32 Correct 529 ms 2068 KB Output is correct
33 Correct 529 ms 2072 KB Output is correct
34 Correct 544 ms 1884 KB Output is correct
35 Correct 540 ms 2068 KB Output is correct
36 Correct 548 ms 2136 KB Output is correct