QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#486817#1819. Cleaning RoboteCompile Error//C++141.8kb2024-07-22 03:49:012024-07-22 03:49:01

Judging History

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

  • [2024-07-22 03:49:01]
  • 评测
  • [2024-07-22 03:49:01]
  • 提交

answer

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

int n, m, k;

bool works(int s, int prefixsum[n + 1][m + 1]){
    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<int> q;
    bool found = false;
    for (int i = 1; i <= n - s; i++){
        for (int j = 1; j <= m - s; j++){
            if (prefixsum[i + s - 1][j + s - 1] - prefixsum[i + s - 1][j] - prefixsum[i][j + s - 1] + prefixsum[i][j] == 0){
                q.push(make_pair(i, j));
                visited[i][j] = true;
                found = true;
                break;
            }
        }
        if (found){break;}
    }
    if (!found){return false;}
    return true;
}

int main(){
    cin >> n >> m >> k;
    int a [n][m];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            a[i][j] = 0;
        }
    }
    for (int i = 0; i < k; i++){
        int x, y;
        cin >> x >> y;
        a[x - 1][y - 1] = 1;
    }
    int prefixsum[n + 1][m + 1];
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= m; j++){
            prefixsum[i][j] = 0;
        }
    }
    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] + a[i - 1][j - 1];
        }
    }
    int left = 0;
    int right = min(n, m);
    while (left < right){
        int mid = (left + right)/2;
        if (works(mid, prefixsum)){
            left = mid;
        }
        else{
            right = mid - 1;
        }
    }
    if (works(left, prefixsum)){
        cout << left;
    }
    else{
        cout << -1;
    }
}

Details

answer.code:7:42: error: size of array ‘prefixsum’ is not an integral constant-expression
    7 | bool works(int s, int prefixsum[n + 1][m + 1]){
      |                                        ~~^~~
answer.code:7:35: error: size of array ‘prefixsum’ is not an integral constant-expression
    7 | bool works(int s, int prefixsum[n + 1][m + 1]){
      |                                 ~~^~~
answer.code: In function ‘bool works(int, int (*)[1])’:
answer.code:19:23: error: no matching function for call to ‘std::queue<int>::push(std::pair<int, int>)’
   19 |                 q.push(make_pair(i, j));
      |                 ~~~~~~^~~~~~~~~~~~~~~~~
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 = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = 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 ‘std::pair<int, int>’ to ‘const std::queue<int>::value_type&’ {aka ‘const 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 = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]’
  290 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:290:25: note:   no known conversion for argument 1 from ‘std::pair<int, int>’ to ‘std::queue<int>::value_type&&’ {aka ‘int&&’}
  290 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
answer.code: In function ‘int main()’:
answer.code:59:24: error: cannot convert ‘int (*)[(m + 1)]’ to ‘int (*)[1]’
   59 |         if (works(mid, prefixsum)){
      |                        ^~~~~~~~~
      |                        |
      |                        int (*)[(m + 1)]
answer.code:7:23: note:   initializing argument 2 of ‘bool works(int, int (*)[1])’
    7 | bool works(int s, int prefixsum[n + 1][m + 1]){
      |                   ~~~~^~~~~~~~~~~~~~~~~~~~~~~
answer.code:66:21: error: cannot convert ‘int (*)[(m + 1)]’ to ‘int (*)[1]’
   66 |     if (works(left, prefixsum)){
      |                     ^~~~~~~~~
      |                     |
      |                     int (*)[(m + 1)]
answer.code:7:23: note:   initializing argument 2 of ‘bool works(int, int (*)[1])’
    7 | bool works(int s, int prefixsum[n + 1][m + 1]){
      |                   ~~~~^~~~~~~~~~~~~~~~~~~~~~~