Submission #843166

# Submission time Handle Problem Language Result Execution time Memory
843166 2023-09-03T18:31:37 Z Mizo_Compiler Tracks in the Snow (BOI13_tracks) C++
0 / 100
148 ms 18480 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
#define pb push_back
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
const int N = 4000;
int n, m, ans = 1;
char c[N][N];
bool fc[N][N];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
vector<pair<int, int>> f, r;
bool vis[N][N];

void dfs(int i, int j) {
	fc[i][j] = true;
	vis[i][j] = true;
	for (int ii = 0; ii < 4; ii++) {
		int nx = i + dx[ii], ny = j + dy[ii];
		if (nx < 0 || ny < 0 || nx >= n || ny >= m)continue;
		if (c[nx][ny] == c[0][0]) {
			if (!fc[nx][ny])dfs(nx, ny);
		} else if (!vis[nx][ny]) {
			if (c[nx][ny] == 'F')f.pb({nx, ny});
			else if (c[nx][ny] == 'R')r.pb({nx, ny});
			vis[nx][ny] = true;
		}
	}
}

int main () {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> c[i][j];
		}
	}
  	return 0;
	dfs(0, 0);
	char cur = 'R';
	if (c[0][0] == cur)cur = 'F';
	while (!f.empty() || !r.empty()) {
		if (cur == 'R') {
			if (!r.empty())ans++;
			while (!r.empty()) {
				int x = r.back().F, y = r.back().S;
				r.pop_back();
				for (int i = 0; i < 4; i++) {
					int nx = x + dx[i], ny = y + dy[i];
					if (nx < 0 || ny < 0 || nx >= n || ny >= m)continue;
					if (vis[nx][ny])continue;
					vis[nx][ny] = true;
					if (c[nx][ny] == 'R')r.pb({nx, ny});
					else if (c[nx][ny] == 'F')f.pb({nx, ny});
				}
			}
		} else {
			if (!f.empty()) {
				ans++;
			}
			while (!f.empty()) {
				int x = f.back().F, y = f.back().S;
				f.pop_back();
				for (int i = 0; i < 4; i++) {
					int nx = x + dx[i], ny = y + dy[i];
					if (nx < 0 || ny < 0 || nx >= n || ny >= m)continue;
					if (vis[nx][ny])continue;
					vis[nx][ny] = true;
					if (c[nx][ny] == 'R')r.pb({nx, ny});
					else if (c[nx][ny] == 'F')f.pb({nx, ny});
				}
			}
		}
		if (cur == 'F')cur = 'R';
		else cur = 'F';
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6488 KB Output isn't correct
2 Incorrect 1 ms 4440 KB Output isn't correct
3 Incorrect 1 ms 4440 KB Output isn't correct
4 Incorrect 2 ms 6488 KB Output isn't correct
5 Incorrect 1 ms 4444 KB Output isn't correct
6 Incorrect 1 ms 4440 KB Output isn't correct
7 Incorrect 1 ms 4440 KB Output isn't correct
8 Incorrect 1 ms 4444 KB Output isn't correct
9 Incorrect 1 ms 4444 KB Output isn't correct
10 Incorrect 1 ms 4440 KB Output isn't correct
11 Incorrect 1 ms 4440 KB Output isn't correct
12 Incorrect 1 ms 4440 KB Output isn't correct
13 Incorrect 1 ms 4444 KB Output isn't correct
14 Incorrect 1 ms 4440 KB Output isn't correct
15 Incorrect 3 ms 6488 KB Output isn't correct
16 Incorrect 3 ms 6488 KB Output isn't correct
17 Incorrect 4 ms 6488 KB Output isn't correct
18 Incorrect 2 ms 6492 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 17756 KB Output isn't correct
2 Incorrect 14 ms 8540 KB Output isn't correct
3 Incorrect 138 ms 18376 KB Output isn't correct
4 Incorrect 38 ms 10580 KB Output isn't correct
5 Incorrect 74 ms 14796 KB Output isn't correct
6 Incorrect 145 ms 18480 KB Output isn't correct
7 Incorrect 3 ms 18264 KB Output isn't correct
8 Incorrect 2 ms 17752 KB Output isn't correct
9 Incorrect 1 ms 4440 KB Output isn't correct
10 Incorrect 1 ms 4440 KB Output isn't correct
11 Incorrect 3 ms 18008 KB Output isn't correct
12 Incorrect 1 ms 4440 KB Output isn't correct
13 Incorrect 16 ms 8536 KB Output isn't correct
14 Incorrect 9 ms 6488 KB Output isn't correct
15 Incorrect 9 ms 8536 KB Output isn't correct
16 Incorrect 6 ms 4440 KB Output isn't correct
17 Incorrect 34 ms 12624 KB Output isn't correct
18 Incorrect 34 ms 10608 KB Output isn't correct
19 Incorrect 31 ms 10584 KB Output isn't correct
20 Incorrect 30 ms 10584 KB Output isn't correct
21 Incorrect 83 ms 17096 KB Output isn't correct
22 Incorrect 76 ms 14672 KB Output isn't correct
23 Incorrect 73 ms 12628 KB Output isn't correct
24 Incorrect 74 ms 16836 KB Output isn't correct
25 Incorrect 134 ms 18380 KB Output isn't correct
26 Incorrect 111 ms 16856 KB Output isn't correct
27 Incorrect 131 ms 18376 KB Output isn't correct
28 Incorrect 148 ms 18368 KB Output isn't correct
29 Incorrect 131 ms 18256 KB Output isn't correct
30 Incorrect 127 ms 18120 KB Output isn't correct
31 Incorrect 120 ms 16840 KB Output isn't correct
32 Incorrect 142 ms 18256 KB Output isn't correct