Submission #958773

#TimeUsernameProblemLanguageResultExecution timeMemory
958773teo_thrashCop and Robber (BOI14_coprobber)C++14
0 / 100
3012 ms262144 KiB
#include "coprobber.h"
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

typedef long long ll;


vector<int> nbrs[MAX_N];

int curr=0;

int start(int N, bool A[MAX_N][MAX_N]){
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(A[i][j]){
                nbrs[i].pb(j);
                nbrs[j].pb(i);
            }
        }
    }

    return 0;
}

int dfs(int x, int y, int to){
    if(x==to) return 0;

    for(auto u: nbrs[x]){
        if(u==y) continue;

        int nas = dfs(u, x, to);

        if(nas!=-1){
            return 1+nas;
        }
    }

    return -1;
}

int nextMove(int R){
    int dist = dfs(curr, -1, R);

    for(auto u: nbrs[curr]){
        if(dfs(u, -1, R)<dist){
            return curr=u;
        }
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...