답안 #793036

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
793036 2023-07-25T12:56:03 Z MODDI Tracks in the Snow (BOI13_tracks) C++14
84.6875 / 100
2000 ms 114648 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(){
	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 48 ms 7324 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 852 KB Output is correct
4 Correct 31 ms 7248 KB Output is correct
5 Correct 8 ms 4064 KB Output is correct
6 Correct 1 ms 432 KB Output is correct
7 Correct 1 ms 852 KB Output is correct
8 Correct 2 ms 952 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 7 ms 3392 KB Output is correct
11 Correct 8 ms 3028 KB Output is correct
12 Correct 18 ms 4220 KB Output is correct
13 Correct 7 ms 4052 KB Output is correct
14 Correct 7 ms 4032 KB Output is correct
15 Correct 38 ms 7152 KB Output is correct
16 Correct 48 ms 7420 KB Output is correct
17 Correct 26 ms 7124 KB Output is correct
18 Correct 31 ms 7272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 45716 KB Output is correct
2 Correct 157 ms 19012 KB Output is correct
3 Correct 750 ms 73632 KB Output is correct
4 Correct 217 ms 36884 KB Output is correct
5 Correct 428 ms 56424 KB Output is correct
6 Execution timed out 2071 ms 114520 KB Time limit exceeded
7 Correct 20 ms 47820 KB Output is correct
8 Correct 20 ms 45716 KB Output is correct
9 Correct 6 ms 796 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 20 ms 46884 KB Output is correct
12 Correct 2 ms 2132 KB Output is correct
13 Correct 147 ms 18952 KB Output is correct
14 Correct 85 ms 13572 KB Output is correct
15 Correct 59 ms 16464 KB Output is correct
16 Correct 71 ms 7212 KB Output is correct
17 Correct 378 ms 33136 KB Output is correct
18 Correct 199 ms 40016 KB Output is correct
19 Correct 215 ms 36804 KB Output is correct
20 Correct 178 ms 29516 KB Output is correct
21 Correct 453 ms 55784 KB Output is correct
22 Correct 389 ms 56424 KB Output is correct
23 Correct 733 ms 46628 KB Output is correct
24 Correct 369 ms 53484 KB Output is correct
25 Correct 897 ms 94588 KB Output is correct
26 Correct 1662 ms 82900 KB Output is correct
27 Execution timed out 2041 ms 96640 KB Time limit exceeded
28 Execution timed out 2059 ms 114648 KB Time limit exceeded
29 Execution timed out 2074 ms 102588 KB Time limit exceeded
30 Execution timed out 2057 ms 99376 KB Time limit exceeded
31 Execution timed out 2081 ms 74820 KB Time limit exceeded
32 Execution timed out 2072 ms 91224 KB Time limit exceeded