답안 #493807

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493807 2021-12-13T03:10:24 Z Haruto810198 Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 9668 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

#define FOR(i, l, r, d) for(int i=(l); i<=(r); i+=(d))
#define szof(x) ((int)(x).size())

#define vi vector<int>
#define pii pair<int, int>

#define F first
#define S second

#define pb push_back
#define eb emplace_back
#define mkp make_pair

const int INF = INT_MAX;
const int LNF = INF*INF;
const int MOD = 1000000007;
const int mod = 998244353;
const double eps = 1e-12;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

const int MAX = 5010;

int r, c, m;
string str;
vector<bitset<MAX>> arr(MAX), dp(MAX), newdp(MAX);
int res;

signed main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>r>>c>>m;
	FOR(i, 1, r, 1){
		FOR(j, 1, c, 1){
			char ch;
			cin>>ch;
			if(ch == '.') dp[i][c+1-j] = arr[i][c+1-j] = 1;
		}
	}

	cin>>str;
	for(char ch : str){
			
		if(ch == 'N'){
			FOR(i, 1, r-1, 1){
				newdp[i] = dp[i+1] & arr[i];
			}
			newdp[r].reset();
		}
		if(ch == 'S'){
			newdp[1].reset();
			FOR(i, 2, r, 1){
				newdp[i] = dp[i-1] & arr[i];
			}
		}
		if(ch == 'E'){
			FOR(i, 1, r, 1){
				newdp[i] = (dp[i] >> 1) & arr[i];
			}
		}
		if(ch == 'W'){
			FOR(i, 1, r, 1){
				newdp[i] = (dp[i] << 1) & arr[i];
			}
		}
		
		if(ch == '?'){
			newdp[1] = dp[2];
			FOR(i, 2, r-1, 1){
				newdp[i] = dp[i-1] | dp[i+1];
			}
			newdp[r] = dp[r-1];
			
			FOR(i, 1, r, 1){
				newdp[i] |= (dp[i] >> 1) | (dp[i] << 1);
			}

			FOR(i, 1, r, 1){
				newdp[i] &= arr[i];
			}
		}
		
		swap(dp, newdp);
		
	}

	FOR(i, 1, r, 1){
		FOR(j, 1, c, 1){
			res += dp[i][j];
		}
	}

	cout<<res<<'\n';
	
	return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 9548 KB Output is correct
2 Correct 6 ms 9548 KB Output is correct
3 Correct 6 ms 9548 KB Output is correct
4 Correct 6 ms 9548 KB Output is correct
5 Correct 6 ms 9548 KB Output is correct
6 Correct 5 ms 9548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 9548 KB Output is correct
2 Correct 6 ms 9548 KB Output is correct
3 Correct 6 ms 9548 KB Output is correct
4 Correct 6 ms 9548 KB Output is correct
5 Correct 6 ms 9548 KB Output is correct
6 Correct 5 ms 9548 KB Output is correct
7 Correct 7 ms 9548 KB Output is correct
8 Correct 7 ms 9548 KB Output is correct
9 Correct 8 ms 9604 KB Output is correct
10 Correct 7 ms 9548 KB Output is correct
11 Correct 7 ms 9548 KB Output is correct
12 Correct 9 ms 9548 KB Output is correct
13 Correct 8 ms 9548 KB Output is correct
14 Correct 11 ms 9548 KB Output is correct
15 Correct 8 ms 9548 KB Output is correct
16 Correct 8 ms 9548 KB Output is correct
17 Correct 9 ms 9548 KB Output is correct
18 Correct 8 ms 9548 KB Output is correct
19 Correct 9 ms 9548 KB Output is correct
20 Correct 8 ms 9548 KB Output is correct
21 Correct 8 ms 9576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 9548 KB Output is correct
2 Correct 6 ms 9548 KB Output is correct
3 Correct 6 ms 9548 KB Output is correct
4 Correct 6 ms 9548 KB Output is correct
5 Correct 6 ms 9548 KB Output is correct
6 Correct 5 ms 9548 KB Output is correct
7 Correct 7 ms 9548 KB Output is correct
8 Correct 7 ms 9548 KB Output is correct
9 Correct 8 ms 9604 KB Output is correct
10 Correct 7 ms 9548 KB Output is correct
11 Correct 7 ms 9548 KB Output is correct
12 Correct 9 ms 9548 KB Output is correct
13 Correct 8 ms 9548 KB Output is correct
14 Correct 11 ms 9548 KB Output is correct
15 Correct 8 ms 9548 KB Output is correct
16 Correct 8 ms 9548 KB Output is correct
17 Correct 9 ms 9548 KB Output is correct
18 Correct 8 ms 9548 KB Output is correct
19 Correct 9 ms 9548 KB Output is correct
20 Correct 8 ms 9548 KB Output is correct
21 Correct 8 ms 9576 KB Output is correct
22 Correct 714 ms 9628 KB Output is correct
23 Correct 617 ms 9668 KB Output is correct
24 Correct 673 ms 9620 KB Output is correct
25 Correct 660 ms 9628 KB Output is correct
26 Correct 672 ms 9636 KB Output is correct
27 Correct 938 ms 9620 KB Output is correct
28 Correct 936 ms 9632 KB Output is correct
29 Correct 921 ms 9624 KB Output is correct
30 Correct 974 ms 9628 KB Output is correct
31 Correct 932 ms 9624 KB Output is correct
32 Execution timed out 1097 ms 9548 KB Time limit exceeded
33 Halted 0 ms 0 KB -