Submission #793045

# Submission time Handle Problem Language Result Execution time Memory
793045 2023-07-25T13:00:28 Z MODDI Tracks in the Snow (BOI13_tracks) C++14
2.1875 / 100
29 ms 18628 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;
vector<string> mat;
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;
	mat.resize(n);
	for(int i = 0; i < n; i++)
		cin>>mat[i];
	
	deque<pii> q;
	int ans = 1;
	dist[0][0] = vis[0][0] = 1;
	while(!q.empty()){
		pii at = q.front();
		q.pop_front();
		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]);
				if(mat[at.first][at.second] != mat[nx][ny])	q.pb(mp(nx,ny));
				else q.push_front(mp(nx,ny));
				//q.push(mp(-dist[nx][ny], mp(nx,ny)));
			}
		}
	}
	cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 728 KB Output isn't correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Incorrect 1 ms 596 KB Output isn't correct
5 Incorrect 1 ms 456 KB Output isn't correct
6 Incorrect 0 ms 340 KB Output isn't correct
7 Incorrect 1 ms 340 KB Output isn't correct
8 Incorrect 1 ms 332 KB Output isn't correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Incorrect 1 ms 468 KB Output isn't correct
11 Incorrect 1 ms 340 KB Output isn't correct
12 Incorrect 1 ms 464 KB Output isn't correct
13 Incorrect 1 ms 468 KB Output isn't correct
14 Incorrect 1 ms 468 KB Output isn't correct
15 Incorrect 1 ms 828 KB Output isn't correct
16 Incorrect 1 ms 728 KB Output isn't correct
17 Incorrect 1 ms 724 KB Output isn't correct
18 Incorrect 1 ms 596 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Output isn't correct
2 Incorrect 4 ms 2480 KB Output isn't correct
3 Incorrect 20 ms 18628 KB Output isn't correct
4 Incorrect 7 ms 4840 KB Output isn't correct
5 Incorrect 13 ms 10580 KB Output isn't correct
6 Incorrect 23 ms 18536 KB Output isn't correct
7 Incorrect 1 ms 500 KB Output isn't correct
8 Incorrect 1 ms 464 KB Output isn't correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Incorrect 1 ms 340 KB Output isn't correct
11 Incorrect 1 ms 468 KB Output isn't correct
12 Incorrect 1 ms 340 KB Output isn't correct
13 Incorrect 4 ms 2440 KB Output isn't correct
14 Incorrect 3 ms 1820 KB Output isn't correct
15 Incorrect 3 ms 2008 KB Output isn't correct
16 Incorrect 2 ms 1364 KB Output isn't correct
17 Incorrect 8 ms 5124 KB Output isn't correct
18 Incorrect 9 ms 5000 KB Output isn't correct
19 Incorrect 6 ms 4776 KB Output isn't correct
20 Incorrect 6 ms 4492 KB Output isn't correct
21 Incorrect 11 ms 10888 KB Output isn't correct
22 Incorrect 11 ms 10664 KB Output isn't correct
23 Incorrect 11 ms 9240 KB Output isn't correct
24 Incorrect 14 ms 10652 KB Output isn't correct
25 Incorrect 29 ms 18576 KB Output isn't correct
26 Correct 16 ms 14332 KB Output is correct
27 Incorrect 19 ms 18624 KB Output isn't correct
28 Incorrect 20 ms 18592 KB Output isn't correct
29 Incorrect 19 ms 18624 KB Output isn't correct
30 Incorrect 20 ms 18060 KB Output isn't correct
31 Incorrect 13 ms 11912 KB Output isn't correct
32 Incorrect 19 ms 18280 KB Output isn't correct