This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "coprobber.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MASK(i) (1LL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ll mask){return __builtin_popcountll(mask);}
int ctz(ll mask){return __builtin_ctzll(mask);}
int logOf(ll mask){return __lg(mask);}
// mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rng(1);
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
template <class T1, class T2>
bool maximize(T1 &a, T2 b){
if (a < b) {a = b; return true;}
return false;
}
template <class T1, class T2>
bool minimize(T1 &a, T2 b){
if (a > b) {a = b; return true;}
return false;
}
template <class T>
void printArr(T& container, string separator = " ", string finish = "\n"){
for(auto item: container) cout << item << separator;
cout << finish;
}
template <class T>
void remove_dup(vector<T> &a){
sort(ALL(a));
a.resize(unique(ALL(a)) - a.begin());
}
const int N = 500;
const int INF = 1e9 + 69;
int graph[N][N];
bool edging[N][N];
int cop;
int n;
int start(int _n, bool A[N][N]){
n = _n;
for(int i = 0; i<n; ++i) for(int j= 0; j<n; ++j) edging[i][j] = A[i][j];
for(int i = 0; i<n; ++i) for(int j = 0; j<n; ++j) {
if (A[i][j]) graph[i][j] = 1;
else graph[i][j] = INF;
if (i == j) graph[i][j] = 0;
}
int biggest_cycle = 0;
for(int k = 0; k<n; ++k){
for(int i = 0; i<n; ++i)
for(int j = 0; j<n; ++j)
if (graph[i][j] < INF && graph[i][k] < INF && graph[k][j] < INF)
maximize(biggest_cycle, graph[i][j] + graph[i][k] + graph[k][j]);
for(int i = 0; i<n; ++i)
for(int j = 0; j<n; ++j)
minimize(graph[i][j], graph[i][k] + graph[k][j]);
}
cop = 0;
return 0;
// if (biggest_cycle <= 4) return 0;
// return -1;
}
int nextMove(int R){
vector<int> S; S.push_back(cop);
for(int i = 0; i<n; ++i) if (edging[cop][i]) S.push_back(i);
// vector<int> T;
// for(int i = 0; i<n; ++i) if (edging[R][i]) T.push_back(i);
pair<int, int> best = {INF, INF};
for(int i: S){
int cur = graph[i][R];
minimize(best, make_pair(cur, i));
}
return best.second;
}
// int main(void){
// ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// int n; cin >> n;
// bool a[N][N];
// memset(a, 0, sizeof a);
// for(int i = 0; i<n; ++i) for(int j = 0; j<n; ++j) cin >> a[i][j];
// int cop = start(n, a);
// cout << "? " << cop << endl;
// int crim; cin >> crim;
// while(cop != crim){
// cop = nextMove(crim);
// if (cop == crim) break;
// cout << "? " << cop << endl;
// cin >> crim;
// }
// cout << "Crim caught!!!!" << endl;
// return 0;
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |