QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#500250#1819. Cleaning RobotaskewwWA 1446ms269040kbC++171.2kb2024-08-01 05:49:582024-08-01 05:50:03

Judging History

你现在查看的是最新测评结果

  • [2024-08-01 05:50:03]
  • 评测
  • 测评结果:WA
  • 用时:1446ms
  • 内存:269040kb
  • [2024-08-01 05:49:58]
  • 提交

answer

#include <iostream>
#include <vector>
using namespace std;

int n, m, k, x, y, size_l, size_r;
vector<vector<bool>> obstructed;

void dfs(int i, int j, int size, vector<vector<bool>>& visited) {
	if (i < 0 || j < 0 || i + size > n || j + size > m) return;
	
	if (obstructed[i][j] || visited[i][j]) return;
	visited[i][j] = true;
	
	dfs(i - 1, j, size, visited);
	dfs(i + 1, j, size, visited);
	dfs(i, j - 1, size, visited);
	dfs(i, j + 1, size, visited);
}

bool check(int size) {
	vector<vector<bool>> visited = vector<vector<bool>>(n, vector<bool>(m, false));
	bool once = false;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (!obstructed[i][j] && !visited[i][j]) {
				if (once) {
					return false;
				} else {
					dfs(i, j, size, visited);
					once = true;
				}
			}
		}
	}
	
	return true;
}

int main() {
	cin >> n >> m >> k;
	obstructed = vector<vector<bool>>(n, vector<bool>(m, false));
	for (int i = 0; i < k; i++) {
		cin >> x >> y;
		obstructed[--x][--y] = true;
	}
	
	size_l = 1;
	size_r = min(n, m);
	while (size_l < size_r) {
		int size_m = (size_l + size_r) / 2;
		
		if (check(size_m)) {
		  size_l = size_m + 1;
		} else {
		  size_r = size_m;
		}
	}
	cout << size_l << endl;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3572kb

input:

10 7 1
8 3

output:

2

result:

ok answer is '2'

Test #2:

score: -100
Wrong Answer
time: 1446ms
memory: 269040kb

input:

2236 2236 2214
28 1255
389 2175
730 592
1360 977
1225 752
1403 1798
1518 1381
147 745
659 249
951 1475
1826 1951
691 1033
81 1458
1487 1946
2106 1395
1995 629
470 891
1902 822
2210 2001
441 2130
1198 1539
2027 1101
215 1149
205 420
379 2104
308 1225
859 109
1417 2078
1764 376
1772 5
335 1113
917 118...

output:

2

result:

wrong answer expected '1', found '2'