Submission #1076199

#TimeUsernameProblemLanguageResultExecution timeMemory
1076199raphaelpCop and Robber (BOI14_coprobber)C++14
0 / 100
2 ms4440 KiB
#include <bits/stdc++.h>
#include "coprobber.h"
using namespace std;
vector<vector<int>> AR;
vector<vector<int>> cop, robber;
int pos = 0;
int start(int N, bool A[500][500])
{
    AR.assign(N, {});
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)

        {
            if (A[i][j])
            {
                AR[i].push_back(j);
                AR[j].push_back(i);
            }
        }
    }
    cop.assign(500, vector<int>(500, -1)), robber.assign(500, vector<int>(500, -1));
    vector<vector<int>> choixcop(500, vector<int>(500)), choixrobber(500, vector<int>(500));
    queue<vector<int>> Q;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            choixrobber[i][j] = AR[j].size();
        }
    }
    for (int i = 0; i < N; i++)
    {
        cop[i][i] = 1;
        for (int j = 0; j < AR[i].size(); j++)
        {
            choixrobber[i][AR[i][j]]--;
            if (choixrobber[i][AR[i][j]] == 0)
                Q.push({i, AR[i][j], 1});
        }
        robber[i][i] = 1;
        choixrobber[i][i] = -1;
        for (int j = 0; j < AR[i].size(); j++)
        {
            Q.push({AR[i][j], i, 0, i});
        }
    }
    while (!Q.empty())
    {
        vector<int> temp = Q.front();
        Q.pop();
        if (temp[2] == 0)
        {
            if (cop[temp[0]][temp[1]])
                continue;
            cop[temp[0]][temp[1]] = temp[3];
            for (int i = 0; i < AR[temp[1]].size(); i++)
            {
                choixrobber[temp[0]][AR[temp[1]][i]]--;
                if (choixrobber[temp[0]][AR[temp[1]][i]] == 0)
                    Q.push({temp[0], AR[temp[1]][i], 1});
            }
        }
        else
        {
            if (robber[temp[0]][temp[1]])
                continue;
            for (int i = 0; i < AR[temp[0]].size(); i++)
            {
                Q.push({AR[temp[0]][i], temp[1], 0, temp[0]});
            }
        }
    }
    int x = -1;
    bool b = 1;
    while (b)
    {
        x++;
        if (x == N)
            return -1;
        b = 0;
        for (int i = 0; i < N; i++)
            if (cop[x][i] != -1)
                b = 1;
    }
    pos = x;
    return x;
}
int nextMove(int R)
{
    pos = cop[pos][R];
    return pos;
}

Compilation message (stderr)

coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:35:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for (int j = 0; j < AR[i].size(); j++)
      |                         ~~^~~~~~~~~~~~~~
coprobber.cpp:43:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for (int j = 0; j < AR[i].size(); j++)
      |                         ~~^~~~~~~~~~~~~~
coprobber.cpp:57:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             for (int i = 0; i < AR[temp[1]].size(); i++)
      |                             ~~^~~~~~~~~~~~~~~~~~~~
coprobber.cpp:68:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |             for (int i = 0; i < AR[temp[0]].size(); i++)
      |                             ~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...