Submission #785878

# Submission time Handle Problem Language Result Execution time Memory
785878 2023-07-17T17:32:17 Z bane Cop and Robber (BOI14_coprobber) C++17
0 / 100
2 ms 3152 KB
#include "coprobber.h"
#include<bits/stdc++.h>

using namespace std;

int win[MAX_N][MAX_N][2];
int go[MAX_N][MAX_N];
int cop; 
int start(int N, bool A[MAX_N][MAX_N])
{

    memset(win, 0, sizeof(win));
    memset(go, 0, sizeof(go));

    
        for (int i = 0; i < N; i++){
            for (int j = 0; j < N; j++){
                //ako sme na ista pozicija, pobeda
                if (i == j){
                    win[i][j][0] = 1;
                    win[i][j][1] = 1;
                    go[i][j] = i;
                    continue;
                }

                //nie sme na poteg
                bool forced_pobeda = 0;
                for (int k = 0; k < N; k++){
                    if (A[i][k]){
                        if (win[k][j][1]) go[i][j] = k;
                        forced_pobeda |= win[k][j][1];
                    }
                }

                win[i][j][0] = forced_pobeda;
                //toj e na poteg
                forced_pobeda = 1;
                for (int k = 0; k < N; k++){
                    if (A[j][k]){
                        forced_pobeda &= win[i][k][0]; 
                    }
                }
                win[i][j][1] = forced_pobeda;

            }
        }
    

    for (int starting = 0; starting < N; starting++){
        bool forced = 1;
        for (int j = 0; j < N; j++){
            forced &= win[starting][j][0];
        }
        if (forced){
            cop = starting;
            return starting;
        }
    }
    return -1;
}

int nextMove(int R)
{
    cop = go[cop][R];
    return cop;;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3152 KB Output is correct
2 Correct 1 ms 3152 KB Output is correct
3 Incorrect 1 ms 3152 KB Cop can catch the robber, but start() returned -1
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 3152 KB Cop can catch the robber, but start() returned -1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3152 KB Output is correct
2 Correct 1 ms 3152 KB Output is correct
3 Incorrect 2 ms 3152 KB Cop can catch the robber, but start() returned -1
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3152 KB Output is correct
2 Correct 1 ms 3152 KB Output is correct
3 Incorrect 1 ms 3152 KB Cop can catch the robber, but start() returned -1
4 Halted 0 ms 0 KB -