Submission #969837

# Submission time Handle Problem Language Result Execution time Memory
969837 2024-04-25T16:24:42 Z starchan Tracks in the Snow (BOI13_tracks) C++17
75.8333 / 100
498 ms 116236 KB
#include<bits/stdc++.h>
using namespace std;
#define in array<int, 2>
#define pf push_front
#define pb push_back
#define pob pop_back
#define pof pop_front
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)

const int LMX = 2e7;
const int INF = LMX+1e5;

char g[LMX]; int n, m;
vector<int> d(LMX, INF);

signed main()
{
	fast();
	cin >> n >> m;
	vector<int> dt = {+m, -m, +1, -1}; 
	for(int i = 0; i < m*n; i++)
		cin >> g[i];
	deque<int> pq;
	pq.pf(0); d[0] = 0;
	while(pq.size())
	{
		int u = pq.front(); pq.pof();
		for(auto x: dt)
		{
			int v = u+x;
			if(v < 0 || (v >= (n*m)) || (g[v] == '.'))
				continue;
			int cn = (g[u] != g[v]); 
			if(d[v] > (d[u]+cn))
			{
				d[v] = d[u]+cn;
				if(cn)
					pq.pb(v);
				else
					pq.pf(v);
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < n*m; i++)
	{
		if(g[i] != '.')
			ans = max(ans, ++d[i]);
	}
	cout << ans << "\n";
	return 0;
}	
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 80852 KB Output isn't correct
2 Correct 18 ms 78680 KB Output is correct
3 Correct 16 ms 78680 KB Output is correct
4 Correct 21 ms 78940 KB Output is correct
5 Correct 18 ms 78684 KB Output is correct
6 Correct 17 ms 78680 KB Output is correct
7 Correct 15 ms 78680 KB Output is correct
8 Incorrect 16 ms 78684 KB Output isn't correct
9 Correct 18 ms 78684 KB Output is correct
10 Correct 17 ms 78644 KB Output is correct
11 Correct 16 ms 78936 KB Output is correct
12 Incorrect 22 ms 78684 KB Output isn't correct
13 Correct 18 ms 78684 KB Output is correct
14 Correct 17 ms 78600 KB Output is correct
15 Correct 23 ms 81008 KB Output is correct
16 Incorrect 24 ms 80988 KB Output isn't correct
17 Correct 23 ms 80988 KB Output is correct
18 Correct 20 ms 78876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 78684 KB Output isn't correct
2 Correct 53 ms 80980 KB Output is correct
3 Correct 249 ms 95316 KB Output is correct
4 Correct 80 ms 82780 KB Output is correct
5 Incorrect 204 ms 89168 KB Output isn't correct
6 Correct 480 ms 102356 KB Output is correct
7 Incorrect 16 ms 78684 KB Output isn't correct
8 Incorrect 16 ms 78684 KB Output isn't correct
9 Correct 17 ms 78684 KB Output is correct
10 Correct 21 ms 78784 KB Output is correct
11 Correct 16 ms 78696 KB Output is correct
12 Correct 16 ms 78684 KB Output is correct
13 Correct 47 ms 80732 KB Output is correct
14 Correct 35 ms 80972 KB Output is correct
15 Correct 32 ms 80920 KB Output is correct
16 Correct 31 ms 80988 KB Output is correct
17 Correct 99 ms 82772 KB Output is correct
18 Correct 93 ms 82772 KB Output is correct
19 Correct 88 ms 82772 KB Output is correct
20 Correct 68 ms 82780 KB Output is correct
21 Correct 158 ms 89160 KB Output is correct
22 Incorrect 224 ms 89168 KB Output isn't correct
23 Correct 177 ms 87124 KB Output is correct
24 Incorrect 154 ms 89164 KB Output isn't correct
25 Correct 353 ms 95132 KB Output is correct
26 Correct 278 ms 116236 KB Output is correct
27 Correct 392 ms 105960 KB Output is correct
28 Correct 473 ms 102604 KB Output is correct
29 Incorrect 498 ms 102012 KB Output isn't correct
30 Correct 454 ms 104900 KB Output is correct
31 Incorrect 364 ms 89168 KB Output isn't correct
32 Correct 360 ms 110324 KB Output is correct