답안 #832820

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
832820 2023-08-21T15:49:53 Z serifefedartar Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 24192 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
#define f first
#define s second
#define MOD 1000000007
#define LOGN 20
#define MAXN 300005

vector<string> grid;
int main() {
	fast
	int R, C, M;
	cin >> R >> C >> M;

	grid = vector<string>(R);
	for (int i = 0; i < R; i++)
		cin >> grid[i];
	string way;
	cin >> way;

	set<pair<int,int>> curr;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) {
			if (grid[i][j] == '.')
				curr.insert({i, j});
		}
	}

	set<pair<int,int>> new_curr;
	for (int i = 0; i < M; i++) {
		new_curr = set<pair<int,int>>();
		if (way[i] == 'W') {
			for (auto u : curr) {
				if (u.s && grid[u.f][u.s-1] == '.')
					new_curr.insert({u.f, u.s-1});
			}
		} else if (way[i] == 'E') {
			for (auto u : curr) {
				if (u.s != C-1 && grid[u.f][u.s+1] == '.')
					new_curr.insert({u.f, u.s+1});
			}
		} else if (way[i] == 'N') {
			for (auto u : curr) {
				if (u.f && grid[u.f-1][u.s] == '.')
					new_curr.insert({u.f-1, u.s});
			}
		} else if (way[i] == 'S') {
			for (auto u : curr) {
				if (u.f != R-1 && grid[u.f+1][u.s] == '.')
					new_curr.insert({u.f+1, u.s});
			}
		} else {
			for (auto u : curr) {
				if (u.s != C-1 && grid[u.f][u.s+1] == '.')
					new_curr.insert({u.f, u.s+1});
				if (u.s && grid[u.f][u.s-1] == '.')
					new_curr.insert({u.f, u.s-1});
				if (u.f != R-1 && grid[u.f+1][u.s] == '.')
					new_curr.insert({u.f+1, u.s});
				if (u.f && grid[u.f-1][u.s] == '.')
					new_curr.insert({u.f-1, u.s});
			}
		}
		swap(curr, new_curr);
	}

	cout << curr.size() << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 1236 KB Output is correct
2 Correct 7 ms 968 KB Output is correct
3 Correct 2 ms 724 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 1236 KB Output is correct
2 Correct 7 ms 968 KB Output is correct
3 Correct 2 ms 724 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 139 ms 1268 KB Output is correct
8 Correct 23 ms 724 KB Output is correct
9 Correct 6 ms 580 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 228 ms 1264 KB Output is correct
13 Correct 156 ms 1080 KB Output is correct
14 Correct 85 ms 880 KB Output is correct
15 Correct 4 ms 468 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 334 ms 1260 KB Output is correct
18 Correct 201 ms 1080 KB Output is correct
19 Correct 63 ms 596 KB Output is correct
20 Correct 23 ms 492 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 1236 KB Output is correct
2 Correct 7 ms 968 KB Output is correct
3 Correct 2 ms 724 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 139 ms 1268 KB Output is correct
8 Correct 23 ms 724 KB Output is correct
9 Correct 6 ms 580 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 228 ms 1264 KB Output is correct
13 Correct 156 ms 1080 KB Output is correct
14 Correct 85 ms 880 KB Output is correct
15 Correct 4 ms 468 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 334 ms 1260 KB Output is correct
18 Correct 201 ms 1080 KB Output is correct
19 Correct 63 ms 596 KB Output is correct
20 Correct 23 ms 492 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Execution timed out 1075 ms 24192 KB Time limit exceeded
23 Halted 0 ms 0 KB -