Submission #1075996

#TimeUsernameProblemLanguageResultExecution timeMemory
1075996aboutonCop and Robber (BOI14_coprobber)C++17
16 / 100
3084 ms2904 KiB
#include "coprobber.h"
#include <bits/stdc++.h>
using namespace std;

int L, C, N;
int pos = 0;
int pere[502];
int A[502][502];

void dfs(int i)
{
    for (int nouv = 0; nouv < N; nouv ++)
    {
        if (!A[i][nouv]) continue;
        if (pere[nouv] == -2)
        {
            pere[nouv] = i;
            dfs(nouv);
        }
    }
}

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];
    for (int i = 0; i < N; i ++) pere[i] = -2;
    pere[0] = -1;
    dfs(0);
    return 0;
}

int nextMove(int R)
{
    int rob = R;
    while (pere[rob] != pos)
    {
        rob = pere[rob];
    }
    pos = rob;
    return pos;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...