Submission #302386

#TimeUsernameProblemLanguageResultExecution timeMemory
302386dantoh000Cop and Robber (BOI14_coprobber)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "coprobber.h"
using namespace std;
typedef tuple<int,int,int> iii;
bool state[505][505][2];
int num[505][505];
int ct[505];
int G[505][505];
int pa[505][505];
int st = -1;
queue<iii> Q;
int start(int N, bool A[MAX_N][MAX_N])
{
    for (int i = 0; i < N; i++){
        for (int j = 0; j < N; j++){
            G[i][j] = A[i][j];
            ct[i] += G[i][j];
        }
        state[i][i][0] = state[i][i][1] = 1;
        pa[i][i][0] = pa[i][i][1] = -1;
        Q.push({i,i,0});
        Q.push({i,i,1});
    }
    while (Q.size()){
        int x, y, flag;
        tie(x,y,flag) = Q.front(); Q.pop();
        if (flag){
            for (int i = 0; i < n; i++){
                if (G[x][i] || i==x){
                    if (state[i][y][0]) continue;
                    pa[i][y] = x;
                    state[i][y][0] = true;
                    Q.push_back({i,y,0});
                }
            }
        }
        else{
            for (int i = 0; i < n; i++){
                if (G[i][y]){
                    num[x][i]++;
                    if (num[x][i] == cnt[i]){
                        state[x][i][1] = true;
                        Q.push({x,i,1});
                    }
                }
            }
        }
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if (state[i][j][0] == false) break;
            if (j == n-1) st = i;
        }
    }
    return st;
}
int nextMove(int R)
{
    return st = pa[st][R];
}

Compilation message (stderr)

coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:20:19: error: invalid types 'int[int]' for array subscript
   20 |         pa[i][i][0] = pa[i][i][1] = -1;
      |                   ^
coprobber.cpp:20:33: error: invalid types 'int[int]' for array subscript
   20 |         pa[i][i][0] = pa[i][i][1] = -1;
      |                                 ^
coprobber.cpp:28:33: error: 'n' was not declared in this scope
   28 |             for (int i = 0; i < n; i++){
      |                                 ^
coprobber.cpp:33:23: error: 'class std::queue<std::tuple<int, int, int> >' has no member named 'push_back'
   33 |                     Q.push_back({i,y,0});
      |                       ^~~~~~~~~
coprobber.cpp:38:33: error: 'n' was not declared in this scope
   38 |             for (int i = 0; i < n; i++){
      |                                 ^
coprobber.cpp:41:38: error: 'cnt' was not declared in this scope; did you mean 'ct'?
   41 |                     if (num[x][i] == cnt[i]){
      |                                      ^~~
      |                                      ct
coprobber.cpp:49:25: error: 'n' was not declared in this scope
   49 |     for (int i = 0; i < n; i++){
      |                         ^