제출 #476525

#제출 시각아이디문제언어결과실행 시간메모리
476525SamAndCop and Robber (BOI14_coprobber)C++17
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <set>
#include <cstring>
#include <cassert>
#include <vector>
#include <queue>

using namespace std;

#define m_p make_pair
#define fi first
#define se second

const int N = 503;

int n;
bool a[N][N];

int cnt[N][N][2];
vector<pair<pair<int, int>, bool> > rg[N][N][2];

void ave(pair<pair<int, int>, bool> x, pair<pair<int, int>, bool> y)
{
    rg[y.fi.fi][y.fi.se][y.se].push_back(x);
    ++cnt[x.fi.fi][x.fi.se][x.se];
}

bool c[N][N][2];
int p[N][N];

int u;
int start(int NN, bool A[MAX_N][MAX_N]) {
    n = NN;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            a[i][j] = A[i][j];
        }
    }

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            ave(m_p(m_p(i, j), 1), m_p(m_p(i, j), 0));
            for (int k = 0; k < n; ++k)
            {
                if (a[i][k])
                {
                    ave(m_p(m_p(i, j), 1), m_p(m_p(k, j), 0));
                }
                if (a[j][k])
                {
                    ave(m_p(m_p(i, j), 0), m_p(m_p(i, k), 1));
                }
            }
        }
    }

    queue<pair<pair<int, int>, bool> > q;

    for (int i = 0; i < n; ++i)
    {
        c[i][i][0] = true;
        q.push(m_p(m_p(i, i), 0));
        c[i][i][1] = true;
        q.push(m_p(m_p(i, i), 1));
    }

    while (!q.empty())
    {
        int u = q.front().fi.fi;
        int r = q.front().fi.se;
        bool z = q.front().se;
        q.pop();

        for (int i = 0; i < rg[u][r][z].size(); ++i)
        {
            pair<pair<int, int>, bool> h = rg[u][r][z][i];
            if (h.se)
            {
                if (!c[h.fi.fi][h.fi.se][h.se])
                {
                    p[h.fi.fi][h.fi.se] = u;
                    c[h.fi.fi][h.fi.se][h.se] = true;
                    q.push(h);
                }
            }
            else
            {
                --cnt[h.fi.fi][h.fi.se][h.se];
                if (cnt[h.fi.fi][h.fi.se][h.se] == 0 && !c[h.fi.fi][h.fi.se][h.se])
                {
                    c[h.fi.fi][h.fi.se][h.se] = true;
                    q.push(h);
                }
            }
        }
    }

    for (u = 0; u < n; ++u)
    {
        bool z = true;
        for (int r = 0; r < n; ++r)
        {
            if (!c[u][r][1])
            {
                z = false;
                break;
            }
        }
        if (z)
        {
            return u;
        }
    }
    return -1;
}

int nextMove(int r) {
    return (u = p[u][r]);
}

컴파일 시 표준 에러 (stderr) 메시지

coprobber.cpp:32:26: error: 'MAX_N' was not declared in this scope
   32 | int start(int NN, bool A[MAX_N][MAX_N]) {
      |                          ^~~~~
coprobber.cpp:32:33: error: 'MAX_N' was not declared in this scope
   32 | int start(int NN, bool A[MAX_N][MAX_N]) {
      |                                 ^~~~~
coprobber.cpp: In function 'int start(...)':
coprobber.cpp:33:9: error: 'NN' was not declared in this scope; did you mean 'N'?
   33 |     n = NN;
      |         ^~
      |         N
coprobber.cpp:38:23: error: 'A' was not declared in this scope
   38 |             a[i][j] = A[i][j];
      |                       ^
coprobber.cpp:78:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |         for (int i = 0; i < rg[u][r][z].size(); ++i)
      |                         ~~^~~~~~~~~~~~~~~~~~~~