답안 #968684

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968684 2024-04-23T20:11:20 Z NintsiChkhaidze Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 604 KB
#include <bits/stdc++.h>
#define ll long long
#define s second
#define f first
#define pb push_back
#define left (h*2),l,(l + r)/2
#define right (h*2+1),(l+r)/2 + 1,r
#define pii pair <int,int>
using namespace std;

const int N = 505;
char a[N][N];
vector <pii> neighbours = {{0,1}, {0,-1}, {1,0}, {-1,0}};
int n,m;
bitset <501> dpold[N],dpnew[N];

bool valid(int x,int y){
	return (x >= 1 && x <= n && y >= 1 && y <= m && a[x][y] == '.');
}

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);

	int k;
	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] == '.') dpold[i][j] = 1;
		}

	string s;
	cin>>s;

	map <char,pii> mp;
	mp['N'] = {-1,0};
	mp['S'] = {1,0};
	mp['E'] = {0,+1};
	mp['W'] = {0,-1};

	for (int i = 0; i < k; i++){

		for (int x = 1; x <= n; x++){
			for (int y = 1; y <= m; y++){
				if (!dpold[x][y]) continue;

				if (s[i] != '?'){
					int dx = mp[s[i]].f,dy = mp[s[i]].s;
					int X = x + dx,Y = y + dy;
					if (valid(X,Y)) dpnew[X][Y] = 1;
					continue;
				}

				for (auto [dx,dy]: neighbours){
					int X = x + dx,Y = y + dy;
					if (valid(X,Y)) dpnew[X][Y] = 1;
				}

			}
		}
		for (int x=1;x<=n; x++)	
			dpold[x] = dpnew[x],dpnew[x] = 0;
	}

	int ans=0;
	for (int i = 1; i <= n; i++)
		ans += dpold[i].count();
	cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
8 Correct 5 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 11 ms 536 KB Output is correct
13 Correct 13 ms 504 KB Output is correct
14 Correct 13 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 11 ms 528 KB Output is correct
18 Correct 14 ms 344 KB Output is correct
19 Correct 10 ms 348 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
8 Correct 5 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 11 ms 536 KB Output is correct
13 Correct 13 ms 504 KB Output is correct
14 Correct 13 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 11 ms 528 KB Output is correct
18 Correct 14 ms 344 KB Output is correct
19 Correct 10 ms 348 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Execution timed out 1066 ms 604 KB Time limit exceeded
23 Halted 0 ms 0 KB -