Submission #938395

# Submission time Handle Problem Language Result Execution time Memory
938395 2024-03-05T05:43:55 Z Sir_Ahmed_Imran Cop and Robber (BOI14_coprobber) C++17
0 / 100
128 ms 2888 KB
                              ///~~~LOTA~~~///
#include "coprobber.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define append push_back
#define add insert
#define nl "\n"
#define ff first
#define ss second
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL)
#define N 500
int r;
int par[N];
int dept[N];
int dist[N][N];
vector<int> g[N];
map<pii,int> x;
void dfs(int v){
    for(auto& i:g[v]){
        if(dept[i]){
            r=max(r,dept[v]-dept[i]);
            if(dept[v]-dept[i]==3){
                x[{v,par[par[v]]}]=1;
                x[{par[par[v]],v}]=1;
                x[{par[v],par[par[par[v]]]}]=1;
                x[{par[par[par[v]]],par[v]}]=1;
            }
        }
        else{
            dept[i]=dept[v]+1;
            par[i]=v;
            dfs(i);
        }
    }
}
int start(int n, bool a[N][N]){
    for(int i=0;i<n;i++)
        for(int j=r=0;j<n;j++)
            if(a[i][j]) g[i].append(j);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j) dist[i][j]=0;
            else if(a[i][j]) dist[i][j]=1;
            else dist[i][j]=N;
        }
    }
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            for(int k=0;k<n;k++)
                dist[i][k]=min(dist[i][k],dist[i][j]+dist[j][k]);
    dept[0]=1;
    dfs(0);
    if(r>3) return -1;
    r=0;
    return 0;
}
int nextMove(int v){
    if(x[{v,r}]) return r;
    pii pi={2*N,N};
    for(auto& i:g[r])
        pi=min(pi,{dist[v][i],i});
    r=pi.ss;
    return r;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 128 ms 2888 KB Output is correct
5 Incorrect 19 ms 2608 KB the situation repeated
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2392 KB Cop can catch the robber, but start() returned -1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Incorrect 0 ms 2392 KB Cop can catch the robber, but start() returned -1
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 128 ms 2888 KB Output is correct
5 Incorrect 19 ms 2608 KB the situation repeated
6 Halted 0 ms 0 KB -