Submission #71320

#TimeUsernameProblemLanguageResultExecution timeMemory
71320someone_aa경찰관과 강도 (BOI14_coprobber)C++17
0 / 100
250 ms22248 KiB
#include "coprobber.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
*/

bool recursion(int c, int r, int t) {
    if(visited[c][r][t]) return dp[c][r][t];
    visited[c][r][t] = true;
    if(c==r) return dp[c][r][t] = true;

    if(t) {
        bool check = true;
        for(int i=0;i<n;i++) {
            if(a[r][i]) check &= recursion(c, i, 0);
        }
        return dp[c][r][t] = check;
    }
    else {
        bool check = recursion(c, r, 1);
        for(int i=0;i<n;i++) {
            if(a[c][i]) {
                check |= recursion(i, r, 1);
            }
        }
        return dp[c][r][t] = check;
    }
}

int curr;

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

    int ind = -1;
    for(int i=0;i<N;i++) {
        bool check = true;
        for(int j=0;j<N;j++) {
            if(!recursion(i, j, 0)) check = false;
        }
        if(check) ind = i;
    }
    curr = ind;
    return ind;
}

int nextMove(int R) {
    if(curr == R) return curr;
    else {
        for(int i=0;i<n;i++) {
            if(a[curr][i] && recursion(i, R, 1)) {
                return i;
            }
        }
    }
}

Compilation message (stderr)

coprobber.cpp: In function 'int nextMove(int)':
coprobber.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...