Submission #71355

#TimeUsernameProblemLanguageResultExecution timeMemory
71355someone_aaCop and Robber (BOI14_coprobber)C++17
0 / 100
2 ms384 KiB
#include "coprobber.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 510;
bool visited[maxn][maxn][2];
bool dp[maxn][maxn][2];
bool a[maxn][maxn];
int n;

/*
    t - 1: robber's turn
    t - 0: cop's turn
*/

int lf[maxn][maxn][2];
int nxt[maxn][maxn];

struct state {
    int c, r, t;
};

int curr;

int start(int N, bool A[MAX_N][MAX_N]) {
    queue<state>q;
    for(int i=0;i<N;i++) {
        int dg = count(A[i], A[i]+N, true);
        q.push({i,i,0});
        q.push({i,i,1});
        for(int j=0;j<N;j++) {
            lf[i][j][0] = 1;
            lf[i][j][1] = dg;
        }
        lf[i][i][0] = lf[i][i][1] = 0;
    }

    int calls = 0;
    while(!q.empty()) {
        state curr = q.front();
        q.pop();

        //cout<<curr.c<<" "<<curr.r<<" Last was: "<<curr.t<<" -> \n";

        calls++;
        if(curr.t) {
            for(int i=0;i<N;i++) {
                if((i==curr.c || A[curr.c][i]) && lf[i][curr.r][0]) {
                    //cout<<"calling: "<<i<<"with state 0"<<"\n";
                    lf[i][curr.r][0] = 0;
                    q.push({i, curr.r, 0});
                    nxt[i][curr.r] = curr.c;
                }
            }
        }
        else {
            for(int i=0;i<N;i++) {
                if(A[curr.r][i] && lf[curr.c][i][1]) {
                    //cout<<"calling: "<<i<<"with state 1"<<"\n";
                    lf[curr.c][i][1]--;
                    if(lf[curr.c][i][1] == 0) {
                        q.push({curr.c,i,1});
                    }
                }
            }
        }
    }

    if(calls == 2 * N * N) return -1;
    else return 0;
}

int nextMove(int R) {
    return curr = nxt[curr][R];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...