QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#486832#1819. Cleaning RoboteCompile Error//C++172.3kb2024-07-22 05:48:222024-07-22 05:48:23

Judging History

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

  • [2024-07-22 05:48:23]
  • 评测
  • [2024-07-22 05:48:22]
  • 提交

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:31:17: error: ‘x’ was not declared in this scope
   31 |                 x = q.top().first; y = q.top().second;
      |                 ^
answer.code:31:23: error: ‘class std::queue<std::pair<int, int> >’ has no member named ‘top’; did you mean ‘pop’?
   31 |                 x = q.top().first; y = q.top().second;
      |                       ^~~
      |                       pop
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: ‘class std::queue<std::pair<int, int> >’ has no member named ‘top’; did you mean ‘pop’?
   31 |                 x = q.top().first; y = q.top().second;
      |                                          ^~~
      |                                          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:39: error: no matching function for call to ‘std::queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)’
   42 |                                 q.push({nx, ny});
      |                                 ~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/13/queue:66,
                 from answer.code:2:
/usr/include/c++/13/bits/stl_queue.h:285:7: note: candidate: ‘void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; value_type = std::pair<int, int>]’
  285 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:285:30: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const std::queue<std::pair<int, int> >::value_type&’ {aka ‘const std::pair<int, int>&’}
  285 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_queue.h:290:7: note: candidate: ‘void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; value_type = std::pair<int, int>]’
  290 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:290:25: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘std::queue<std::pair<int, int> >::value_type&&’ {aka ‘std::pair<int, int>&&’}
  290 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
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