답안 #968682

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968682 2024-04-23T20:08:25 Z NintsiChkhaidze Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 2908 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];
int dpold[N][N],dpnew[N][N];
vector <pii> neighbours = {{0,1}, {0,-1}, {1,0}, {-1,0}};
int n,m;

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;
					int 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++)	
			for (int y=1;y<=m;y++)
				dpold[x][y] = dpnew[x][y],dpnew[x][y] = 0;
	}

	int ans=0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			ans += dpold[i][j];
	cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2652 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 2 ms 2652 KB Output is correct
6 Correct 2 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2652 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 2 ms 2652 KB Output is correct
6 Correct 2 ms 2652 KB Output is correct
7 Correct 8 ms 2652 KB Output is correct
8 Correct 7 ms 2652 KB Output is correct
9 Correct 3 ms 2652 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 2 ms 2648 KB Output is correct
12 Correct 10 ms 2524 KB Output is correct
13 Correct 13 ms 2652 KB Output is correct
14 Correct 12 ms 2648 KB Output is correct
15 Correct 2 ms 2652 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 10 ms 2652 KB Output is correct
18 Correct 14 ms 2648 KB Output is correct
19 Correct 11 ms 2648 KB Output is correct
20 Correct 4 ms 2528 KB Output is correct
21 Correct 2 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2652 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 2 ms 2652 KB Output is correct
6 Correct 2 ms 2652 KB Output is correct
7 Correct 8 ms 2652 KB Output is correct
8 Correct 7 ms 2652 KB Output is correct
9 Correct 3 ms 2652 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 2 ms 2648 KB Output is correct
12 Correct 10 ms 2524 KB Output is correct
13 Correct 13 ms 2652 KB Output is correct
14 Correct 12 ms 2648 KB Output is correct
15 Correct 2 ms 2652 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 10 ms 2652 KB Output is correct
18 Correct 14 ms 2648 KB Output is correct
19 Correct 11 ms 2648 KB Output is correct
20 Correct 4 ms 2528 KB Output is correct
21 Correct 2 ms 2652 KB Output is correct
22 Execution timed out 1068 ms 2908 KB Time limit exceeded
23 Halted 0 ms 0 KB -