Submission #854142

#TimeUsernameProblemLanguageResultExecution timeMemory
854142fabijan_cikacCop and Robber (BOI14_coprobber)C++17
16 / 100
43 ms8080 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back //T = 0 - policajac na redu struct state{ int T, C, R; }; const int N = 500; vector<int> v[N]; int bio[2][N][N], dp[2][N][N]; int cnt[N][N], best[N][N]; int curr; int start(int n, bool a[N][N]){ for (int i = 0; i < n; ++i){ for (int j = 0; j < n; ++j){ if (a[i][j]) v[i].pb(j); } } queue<state> q; for (int i = 0; i < n; ++i){ q.push({0, i, i}); q.push({1, i, i}); bio[0][i][i] = 1; bio[1][i][i] = 1; dp[0][i][i] = 1; dp[1][i][i] = 1; } for (int i = 0; i < n; ++i){ for (int j = 0; j < n; ++j) cnt[i][j] = (int)(v[j].size()); } while (!q.empty()){ state X = q.front(); q.pop(); if (!X.T){ --cnt[X.C][X.R]; if (cnt[X.C][X.R] == 0){ bio[1][X.C][X.R] = 1; dp[1][X.C][X.R] = 1; q.push({1, X.C, X.R}); } for (int z: v[X.R]){ --cnt[X.C][z]; if (cnt[X.C][z] == 0){ bio[1][X.C][z] = 1; dp[1][X.C][z] = 1; q.push({1, X.C, z}); } } } else{ for (int z: v[X.C]){ if (!bio[0][z][X.R]){ best[z][X.R] = X.C; bio[0][z][X.R] = 1; dp[0][z][X.R] = 1; q.push({0, z, X.R}); } } } } int idx = -1; for (int i = 0; i < n; ++i){ int num = n; for (int j = 0; j < n; ++j) num -= dp[0][i][j]; if (num == 0) idx = i; } curr = idx; return idx; } int nextMove(int R){ return curr = best[curr][R]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...