Submission #971865

# Submission time Handle Problem Language Result Execution time Memory
971865 2024-04-29T12:12:07 Z pete555 Tracks in the Snow (BOI13_tracks) C++17
0 / 100
847 ms 277268 KB
#include<bits/stdc++.h>
using namespace std;

#define pi pair<int,int>
#define ll long long
#define pb push_back
#define pf push_front

const int MOD = 1e9+7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int main()
{
	cin.tie(0)->sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	string s[n];
	for(int i=0; i<n; i++)
		cin >> s[i];
	deque<pi> q;
	vector<vector<int>> d(n, vector<int>(m));
	vector<vector<bool>> vis(n, vector<bool>(m));
	d[0][0] = 0;
	q.pb({0, 0});
	while(q.size()){
		pi u = q.front();
		q.pop_front();
		if(vis[u.first][u.second]) continue;
		vis[u.first][u.second] = true;
		for(int i=0; i<4; i++){
			int new_x = u.first + dx[i];
			int new_y = u.second + dy[i];
			if(new_x < 0 or new_x >= n or new_y < 0 or new_y >= m) continue;
			if(s[new_x][new_y] == s[u.first][u.second]){
				d[new_x][new_y] = d[u.first][u.second];
				q.pf({new_x, new_y});
			}else if(s[new_x][new_y] != '.'){
				d[new_x][new_y] = d[u.first][u.second] + 1;
				q.pb({new_x, new_y});
			}
		}
	}
	cout << d[n-1][m-1] << '\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 2136 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Incorrect 7 ms 1748 KB Output isn't correct
5 Incorrect 2 ms 860 KB Output isn't correct
6 Incorrect 0 ms 456 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Incorrect 1 ms 360 KB Output isn't correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Incorrect 2 ms 860 KB Output isn't correct
11 Incorrect 2 ms 860 KB Output isn't correct
12 Incorrect 6 ms 1116 KB Output isn't correct
13 Incorrect 2 ms 860 KB Output isn't correct
14 Incorrect 2 ms 976 KB Output isn't correct
15 Incorrect 12 ms 2132 KB Output isn't correct
16 Incorrect 15 ms 2216 KB Output isn't correct
17 Incorrect 7 ms 1884 KB Output isn't correct
18 Incorrect 7 ms 1884 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1112 KB Output isn't correct
2 Incorrect 41 ms 10076 KB Output isn't correct
3 Incorrect 214 ms 98736 KB Output isn't correct
4 Incorrect 51 ms 23448 KB Output isn't correct
5 Incorrect 146 ms 55636 KB Output isn't correct
6 Incorrect 847 ms 134308 KB Output isn't correct
7 Incorrect 2 ms 1112 KB Output isn't correct
8 Incorrect 2 ms 1268 KB Output isn't correct
9 Incorrect 2 ms 880 KB Output isn't correct
10 Incorrect 1 ms 604 KB Output isn't correct
11 Incorrect 2 ms 1116 KB Output isn't correct
12 Incorrect 1 ms 500 KB Output isn't correct
13 Incorrect 42 ms 10076 KB Output isn't correct
14 Incorrect 25 ms 5980 KB Output isn't correct
15 Incorrect 12 ms 6492 KB Output isn't correct
16 Incorrect 22 ms 4444 KB Output isn't correct
17 Incorrect 105 ms 25208 KB Output isn't correct
18 Incorrect 62 ms 25152 KB Output isn't correct
19 Incorrect 49 ms 23448 KB Output isn't correct
20 Incorrect 50 ms 21340 KB Output isn't correct
21 Incorrect 126 ms 57428 KB Output isn't correct
22 Incorrect 145 ms 55624 KB Output isn't correct
23 Incorrect 209 ms 48192 KB Output isn't correct
24 Incorrect 108 ms 56148 KB Output isn't correct
25 Incorrect 383 ms 98648 KB Output isn't correct
26 Incorrect 593 ms 277268 KB Output isn't correct
27 Incorrect 685 ms 199840 KB Output isn't correct
28 Incorrect 824 ms 134592 KB Output isn't correct
29 Incorrect 819 ms 129372 KB Output isn't correct
30 Incorrect 756 ms 158792 KB Output isn't correct
31 Incorrect 659 ms 65116 KB Output isn't correct
32 Incorrect 629 ms 186124 KB Output isn't correct