Submission #1070763

#TimeUsernameProblemLanguageResultExecution timeMemory
1070763ortsacCop and Robber (BOI14_coprobber)C++17
0 / 100
159 ms262144 KiB
#include <bits/stdc++.h>
#include "coprobber.h"

using namespace std;

int atual = 0;
int n;

vector<vector<int>> adj;
int has[MAX_N][MAX_N];

int start(int N, bool A[MAX_N][MAX_N]) {
    // realmente não importa qual posição ele inicia
    // pq ele pode só ir andando pra qualquer uma e o cara escolhe de qualquer jeito então fodase
    n = N;
    adj.resize(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (A[i][j]) adj[i].push_back(j);
            has[i][j] = A[i][j];
        }
    }
    return 0;
}

int temR;

bool dfs(int node, int dad) {
    for (auto u : adj[node]) {
        if (u == dad) continue;
        if (dfs(u, node)) {
            if (node == atual) temR = u;
            return true;
        }
    }
    return false;
}

int nextMove(int r) { // IDEALMENTE O(N)
    if (has[r][atual]) return r;
    dfs(0, -1);
    atual = temR;
    return temR;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...