#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back
#define endl '\n'
#define sz(a) a.size()
#define setbits(x) __builtin_popcountll(x)
#define ff first
#define ss second
#define conts continue
#define ceil2(x, y) ((x + y - 1) / (y))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep1(i, n) for(int i = 1; i <= n; ++i)
#define rev(i, s, e) for(int i = s; i >= e; --i)
#define trav(i, a) for(auto &i : a)
template<typename T>
void amin(T &a, T b) {
a = min(a, b);
}
template<typename T>
void amax(T &a, T b) {
a = max(a, b);
}
#ifdef LOCAL
#include "debug.h"
#else
#define debug(x) 42
#endif
/*
refs:
edi
*/
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
const int inf1 = int(1e9) + 5;
const ll inf2 = ll(1e18) + 5;
#include "coprobber.h"
int n;
int dp[MAX_N][MAX_N][2];
bool a[MAX_N][MAX_N];
vector<int> adj[MAX_N];
int pos;
int par[MAX_N][MAX_N][2];
int start(int n_, bool a_[MAX_N][MAX_N])
{
n = n_;
rep(i,MAX_N){
adj[i].clear();
}
rep(i,MAX_N){
rep(j,MAX_N){
a[i][j] = a_[i][j];
if(a[i][j]){
adj[i].pb(j);
}
}
}
memset(dp,-1,sizeof dp);
memset(par,-1,sizeof par);
queue<array<int,3>> q;
rep(i,n){
dp[i][i][0] = 1;
dp[i][i][1] = 0;
q.push({i,i,0});
q.push({i,i,1});
}
rep(iter,inf1){
int change = 0;
rep(i,n){
rep(j,n){
rep(k,2){
if(dp[i][j][k] != -1) conts;
int lose = 0, win = 0, draw = 0;
int losev = -1;
if(k == 0){
trav(v,adj[i]){
auto val = dp[v][j][k^1];
if(val == -1) draw++;
if(val == 0) lose++, losev = v;
if(val == 1) win++;
}
{
int v = i;
auto val = dp[v][j][k^1];
if(val == -1) draw++;
if(val == 0) lose++, losev = v;
if(val == 1) win++;
}
if(lose >= 1){
dp[i][j][k] = 1;
par[i][j][k] = losev;
change++;
}
else{
if(draw == 0){
dp[i][j][k] = 0;
change++;
}
}
}
else{
trav(v,adj[j]){
auto val = dp[i][v][k^1];
if(val == -1) draw++;
if(val == 0) lose++, losev = v;
if(val == 1) win++;
}
if(lose >= 1){
dp[i][j][k] = 1;
par[i][j][k] = losev;
change++;
}
else{
if(draw == 0){
dp[i][j][k] = 0;
change++;
}
}
}
}
}
}
if(!change){
break;
}
}
// int win_cnt[n][n][2], lose_cnt[n][n][2];
// memset(win_cnt,0,sizeof win_cnt);
// memset(lose_cnt,0,sizeof lose_cnt);
// rep(i,n){
// rep(j,n){
// if(i == j) conts;
// rep(k,2){
// if(k == 0){
// win_cnt[i][j][k] = sz(adj[i])+1;
// }
// else{
// lose_cnt[i][j][k] = sz(adj[j]);
// }
// }
// }
// }
// while(!q.empty()){
// auto [i,j,k] = q.front();
// q.pop();
// if(k == 0){
// // police wins, sub 1 from lose_cnt[i][v][k^1]
// if(dp[i][j][k]){
// trav(v,adj[j]){
// if(dp[i][v][k^1] == -1){
// lose_cnt[i][v][k^1]--;
// if(!lose_cnt[i][v][k^1]){
// q.push({i,v,k^1});
// dp[i][v][k^1] = 0;
// }
// }
// }
// }
// // police loses, add unvis adj robber states
// else{
// trav(v,adj[j]){
// if(dp[i][v][k^1] == -1){
// q.push({i,v,k^1});
// dp[i][v][k^1] = 1;
// }
// }
// }
// }
// else{
// // robber loses, add unvis adj police states
// if(!dp[i][j][k]){
// trav(v,adj[i]){
// if(dp[v][j][k^1] == -1){
// q.push({v,j,k^1});
// dp[v][j][k^1] = 1;
// }
// }
// {
// int v = j;
// if(dp[v][j][k^1] == -1){
// q.push({v,j,k^1});
// dp[v][j][k^1] = 1;
// }
// }
// }
// // robber wins, sub 1 from win_cnt[v][j][k^1]
// else{
// trav(v,adj[i]){
// if(dp[v][j][k^1] == -1){
// win_cnt[v][j][k^1]--;
// if(!win_cnt[v][j][k^1]){
// q.push({v,j,k^1});
// dp[v][j][k^1] = 0;
// }
// }
// }
// {
// int v = i;
// if(dp[v][j][k^1] == -1){
// win_cnt[v][j][k^1]--;
// if(!win_cnt[v][j][k^1]){
// q.push({v,j,k^1});
// dp[v][j][k^1] = 0;
// }
// }
// }
// }
// }
// }
// rep(i,n){
// rep(j,n){
// cout << dp[i][j][0] << " " << dp[i][j][1] << endl;
// }
// cout << endl;
// }
pos = -1;
rep(u,n){
bool ok = true;
rep(v,n){
if(dp[u][v][0] != 1){
ok = false;
}
}
if(ok){
pos = u;
}
}
return pos;
}
int nextMove(int v)
{
pos = par[pos][v][0];
return pos;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4696 KB |
Output is correct |
2 |
Correct |
2 ms |
4696 KB |
Output is correct |
3 |
Correct |
1 ms |
4696 KB |
Output is correct |
4 |
Correct |
992 ms |
5932 KB |
Output is correct |
5 |
Correct |
24 ms |
5072 KB |
Output is correct |
6 |
Correct |
95 ms |
5952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4696 KB |
Output is correct |
3 |
Correct |
154 ms |
5940 KB |
Output is correct |
4 |
Correct |
560 ms |
5944 KB |
Output is correct |
5 |
Correct |
143 ms |
5860 KB |
Output is correct |
6 |
Correct |
398 ms |
6188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4696 KB |
Output is correct |
3 |
Correct |
1 ms |
4696 KB |
Output is correct |
4 |
Correct |
1 ms |
4696 KB |
Output is correct |
5 |
Correct |
1 ms |
4696 KB |
Output is correct |
6 |
Correct |
1 ms |
4696 KB |
Output is correct |
7 |
Correct |
2 ms |
4696 KB |
Output is correct |
8 |
Correct |
2 ms |
4696 KB |
Output is correct |
9 |
Correct |
1 ms |
4692 KB |
Output is correct |
10 |
Correct |
3 ms |
4696 KB |
Output is correct |
11 |
Correct |
7 ms |
4696 KB |
Output is correct |
12 |
Correct |
2 ms |
4696 KB |
Output is correct |
13 |
Correct |
2 ms |
4696 KB |
Output is correct |
14 |
Correct |
10 ms |
4696 KB |
Output is correct |
15 |
Correct |
3 ms |
4696 KB |
Output is correct |
16 |
Correct |
4 ms |
4696 KB |
Output is correct |
17 |
Correct |
22 ms |
5000 KB |
Output is correct |
18 |
Correct |
3 ms |
4696 KB |
Output is correct |
19 |
Correct |
1 ms |
4696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4696 KB |
Output is correct |
2 |
Correct |
2 ms |
4696 KB |
Output is correct |
3 |
Correct |
1 ms |
4696 KB |
Output is correct |
4 |
Correct |
992 ms |
5932 KB |
Output is correct |
5 |
Correct |
24 ms |
5072 KB |
Output is correct |
6 |
Correct |
95 ms |
5952 KB |
Output is correct |
7 |
Correct |
1 ms |
4696 KB |
Output is correct |
8 |
Correct |
1 ms |
4696 KB |
Output is correct |
9 |
Correct |
154 ms |
5940 KB |
Output is correct |
10 |
Correct |
560 ms |
5944 KB |
Output is correct |
11 |
Correct |
143 ms |
5860 KB |
Output is correct |
12 |
Correct |
398 ms |
6188 KB |
Output is correct |
13 |
Correct |
1 ms |
4696 KB |
Output is correct |
14 |
Correct |
1 ms |
4696 KB |
Output is correct |
15 |
Correct |
1 ms |
4696 KB |
Output is correct |
16 |
Correct |
1 ms |
4696 KB |
Output is correct |
17 |
Correct |
1 ms |
4696 KB |
Output is correct |
18 |
Correct |
1 ms |
4696 KB |
Output is correct |
19 |
Correct |
2 ms |
4696 KB |
Output is correct |
20 |
Correct |
2 ms |
4696 KB |
Output is correct |
21 |
Correct |
1 ms |
4692 KB |
Output is correct |
22 |
Correct |
3 ms |
4696 KB |
Output is correct |
23 |
Correct |
7 ms |
4696 KB |
Output is correct |
24 |
Correct |
2 ms |
4696 KB |
Output is correct |
25 |
Correct |
2 ms |
4696 KB |
Output is correct |
26 |
Correct |
10 ms |
4696 KB |
Output is correct |
27 |
Correct |
3 ms |
4696 KB |
Output is correct |
28 |
Correct |
4 ms |
4696 KB |
Output is correct |
29 |
Correct |
22 ms |
5000 KB |
Output is correct |
30 |
Correct |
3 ms |
4696 KB |
Output is correct |
31 |
Correct |
1 ms |
4696 KB |
Output is correct |
32 |
Correct |
1 ms |
4696 KB |
Output is correct |
33 |
Correct |
1 ms |
4696 KB |
Output is correct |
34 |
Correct |
1 ms |
4696 KB |
Output is correct |
35 |
Correct |
931 ms |
5940 KB |
Output is correct |
36 |
Correct |
24 ms |
5208 KB |
Output is correct |
37 |
Correct |
96 ms |
5924 KB |
Output is correct |
38 |
Correct |
1 ms |
4696 KB |
Output is correct |
39 |
Correct |
2 ms |
4708 KB |
Output is correct |
40 |
Correct |
197 ms |
5932 KB |
Output is correct |
41 |
Correct |
561 ms |
6016 KB |
Output is correct |
42 |
Correct |
146 ms |
5864 KB |
Output is correct |
43 |
Correct |
414 ms |
5844 KB |
Output is correct |
44 |
Correct |
1 ms |
4696 KB |
Output is correct |
45 |
Correct |
1 ms |
4548 KB |
Output is correct |
46 |
Correct |
1 ms |
4696 KB |
Output is correct |
47 |
Correct |
1 ms |
4696 KB |
Output is correct |
48 |
Correct |
3 ms |
4696 KB |
Output is correct |
49 |
Correct |
7 ms |
4744 KB |
Output is correct |
50 |
Correct |
2 ms |
4696 KB |
Output is correct |
51 |
Correct |
3 ms |
4696 KB |
Output is correct |
52 |
Correct |
10 ms |
4696 KB |
Output is correct |
53 |
Correct |
2 ms |
4696 KB |
Output is correct |
54 |
Correct |
4 ms |
4696 KB |
Output is correct |
55 |
Correct |
25 ms |
4980 KB |
Output is correct |
56 |
Correct |
2 ms |
4696 KB |
Output is correct |
57 |
Correct |
8 ms |
4624 KB |
Output is correct |
58 |
Correct |
22 ms |
4696 KB |
Output is correct |
59 |
Correct |
45 ms |
5240 KB |
Output is correct |
60 |
Correct |
325 ms |
6936 KB |
Output is correct |
61 |
Correct |
367 ms |
5164 KB |
Output is correct |
62 |
Correct |
295 ms |
5428 KB |
Output is correct |
63 |
Execution timed out |
2319 ms |
6736 KB |
Time limit exceeded |
64 |
Halted |
0 ms |
0 KB |
- |