답안 #793037

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
793037 2023-07-25T12:56:53 Z MODDI Tracks in the Snow (BOI13_tracks) C++14
89.0625 / 100
2000 ms 114392 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
using namespace std;
int n, m;
char mat[4001][4001];
bool vis[4001][4001];
int dist[4001][4001], dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
bool in_range(int i, int j){
	if(i >= 0 && j >= 0 && i < n && j < m)	return true;
	return false;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			cin>>mat[i][j];
			
	priority_queue<pair<int, pii>> q;
	q.push(mp(0, mp(0, 0)));
	int ans = 1;
	dist[0][0] = vis[0][0] = 1;
	while(!q.empty()){
		pii at = q.top().second;
		q.pop();
		ans = max(ans, dist[at.first][at.second]);
		for(int dir = 0; dir < 4; dir++){
			int nx = at.first + dx[dir], ny = at.second + dy[dir];
			if(in_range(nx, ny) && mat[nx][ny] != '.' && !vis[nx][ny]){
				vis[nx][ny] = true;
				dist[nx][ny] = dist[at.first][at.second] + (mat[at.first][at.second] != mat[nx][ny]);
				q.push(mp(-dist[nx][ny], mp(nx,ny)));
			}
		}
	}
	cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 7204 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 852 KB Output is correct
4 Correct 26 ms 7160 KB Output is correct
5 Correct 5 ms 3924 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 1 ms 852 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 6 ms 3412 KB Output is correct
11 Correct 7 ms 2900 KB Output is correct
12 Correct 15 ms 4200 KB Output is correct
13 Correct 5 ms 3924 KB Output is correct
14 Correct 5 ms 3924 KB Output is correct
15 Correct 33 ms 6968 KB Output is correct
16 Correct 41 ms 7232 KB Output is correct
17 Correct 20 ms 6848 KB Output is correct
18 Correct 27 ms 7136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 45716 KB Output is correct
2 Correct 110 ms 18484 KB Output is correct
3 Correct 397 ms 73344 KB Output is correct
4 Correct 131 ms 36380 KB Output is correct
5 Correct 182 ms 56260 KB Output is correct
6 Execution timed out 2087 ms 114320 KB Time limit exceeded
7 Correct 20 ms 47836 KB Output is correct
8 Correct 19 ms 45640 KB Output is correct
9 Correct 5 ms 724 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 19 ms 46804 KB Output is correct
12 Correct 1 ms 2132 KB Output is correct
13 Correct 110 ms 18472 KB Output is correct
14 Correct 63 ms 13096 KB Output is correct
15 Correct 25 ms 15956 KB Output is correct
16 Correct 61 ms 6928 KB Output is correct
17 Correct 282 ms 32628 KB Output is correct
18 Correct 112 ms 39536 KB Output is correct
19 Correct 131 ms 36336 KB Output is correct
20 Correct 104 ms 29084 KB Output is correct
21 Correct 253 ms 55628 KB Output is correct
22 Correct 184 ms 56264 KB Output is correct
23 Correct 546 ms 46208 KB Output is correct
24 Correct 154 ms 53068 KB Output is correct
25 Correct 510 ms 94284 KB Output is correct
26 Correct 1395 ms 82680 KB Output is correct
27 Execution timed out 2075 ms 96700 KB Time limit exceeded
28 Execution timed out 2044 ms 114392 KB Time limit exceeded
29 Execution timed out 2078 ms 105912 KB Time limit exceeded
30 Execution timed out 2087 ms 102592 KB Time limit exceeded
31 Correct 1886 ms 76232 KB Output is correct
32 Correct 1927 ms 95508 KB Output is correct