QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#486831 | #1819. Cleaning Robot | e | Compile Error | / | / | C++17 | 2.3kb | 2024-07-22 05:47:15 | 2024-07-22 05:47:15 |
Judging History
answer
#include <iostream>
#include <queue>
using namespace std;
int n, m, k;
vector<vector<int>> prefixsum;
bool works(int s){
bool visited[n + 1][m + 1];
for (int i = 0; i <= n; i++){
for (int j = 0; j <= m; j++){
visited[i][j] = false;
}
}
queue<pair(int, int)> q;
bool found = false;
for (int i = 1; i <= n - s + 1; i++){
for (int j = 1; j <= m - s + 1; j++){
if (prefixsum[i + s - 1][j + s - 1] - prefixsum[i + s - 1][j - 1] - prefixsum[i - 1][j + s - 1] + prefixsum[i - 1][j - 1] == 0){
q.push({i, j});
visited[i][j] = true;
found = true;
break;
}
}
if (found){break;}
}
if (!found){return false;}
vector<vector<int>> clean (n + 2, vector<int>(m + 1, 0));
while (!q.empty()) {
x = q.top().first; y = q.top().second;
q.pop();
clean[x][y]++;
clean[x + s][y]--;
clean[x][y + s]--;
clean[x + s][y + s]++;
dx = {0, 0, 1, -1};
dy = {1, -1, 0, 0};
for (int i = 0; i < 4; i++) {
int nx = x + dx[i], ny = y + dy[i];
if (nx > 0 && nx <= n - s + 1 && ny > 0 && ny <= m - s + 1 && !visited[nx][ny] && prefixsum[nx + s - 1] [ny + s- 1] - prefixsum[nx + s - 1][nx - 1] - prefixsum[ny - 1][ny + s - 1] + prefixsum[nx - 1][ny - 1] == 0) {
q.push({nx, ny});
visited[nx][ny] = true;
}
}
}
int count = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
clean[i][j] += clean[i - 1][j] + clean[i][j - 1] - cleanpi - 1][j - 1];
if (clean[i][j] > 0) count++;
}
}
return count == n * m - k;
}
int main(){
cin >> n >> m >> k;
prefixsum.resize(n + 1, vector<int>(m + 1, 0));
for (int i = 0; i < k; i++){
int x, y;
cin >> x >> y;
prefixsum[x][y] = 1;
}
for (int i = 1; i <= n; i++){
for (int j = 0; j <= m; j++){
prefixsum[i][j] += prefixsum[i - 1][j] + prefixsum[i][j - 1] - prefixsum[i - 1][j - 1];
}
}
int left = 0;
int right = min(n, m);
while (left < right){
int mid = (left + right)/2;
if (works(mid)){
left = mid;
}
else{
right = mid - 1;
}
}
if (works(left)){
cout << left;
}
else{
cout << -1;
}
}
詳細信息
answer.code: In function ‘bool works(int)’: answer.code:15:25: error: template argument 1 is invalid 15 | queue<pair(int, int)> q; | ^ answer.code:15:25: error: template argument 2 is invalid answer.code:20:35: error: request for member ‘push’ in ‘q’, which is of non-class type ‘int’ 20 | q.push({i, j}); | ^~~~ answer.code:30:19: error: request for member ‘empty’ in ‘q’, which is of non-class type ‘int’ 30 | while (!q.empty()) { | ^~~~~ answer.code:31:17: error: ‘x’ was not declared in this scope 31 | x = q.top().first; y = q.top().second; | ^ answer.code:31:23: error: request for member ‘top’ in ‘q’, which is of non-class type ‘int’ 31 | x = q.top().first; y = q.top().second; | ^~~ answer.code:31:36: error: ‘y’ was not declared in this scope 31 | x = q.top().first; y = q.top().second; | ^ answer.code:31:42: error: request for member ‘top’ in ‘q’, which is of non-class type ‘int’ 31 | x = q.top().first; y = q.top().second; | ^~~ answer.code:32:19: error: request for member ‘pop’ in ‘q’, which is of non-class type ‘int’ 32 | q.pop(); | ^~~ answer.code:37:17: error: ‘dx’ was not declared in this scope 37 | dx = {0, 0, 1, -1}; | ^~ answer.code:38:17: error: ‘dy’ was not declared in this scope 38 | dy = {1, -1, 0, 0}; | ^~ answer.code:41:58: error: ‘ny’ was not declared in this scope; did you mean ‘nx’? 41 | if (nx > 0 && nx <= n - s + 1 && ny > 0 && ny <= m - s + 1 && !visited[nx][ny] && prefixsum[nx + s - 1] [ny + s- 1] - prefixsum[nx + s - 1][nx - 1] - prefixsum[ny - 1][ny + s - 1] + prefixsum[nx - 1][ny - 1] == 0) { | ^~ | nx answer.code:42:35: error: request for member ‘push’ in ‘q’, which is of non-class type ‘int’ 42 | q.push({nx, ny}); | ^~~~ answer.code:50:76: error: ‘cleanpi’ was not declared in this scope; did you mean ‘clean’? 50 | clean[i][j] += clean[i - 1][j] + clean[i][j - 1] - cleanpi - 1][j - 1]; | ^~~~~~~ | clean