# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1026761 |
2024-07-18T10:43:57 Z |
dozer |
Game (IOI14_game) |
C++14 |
|
1000 ms |
2960 KB |
#include "game.h"
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define sp " "
#define endl "\n"
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt","w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define LL node * 2
#define RR node * 2
#define mid (l + r) / 2
#define ll long long
#define MAXN 1600
const int modulo = 1e9 + 7;
const ll INF = 2e18 +7;
int N;
bitset<MAXN> adj[MAXN];
set<int> child[MAXN];
int par[MAXN], tin[MAXN], tout[MAXN], cntr, sz[MAXN];
void initialize(int n) {
N = n;
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++) adj[i].set(j, 1);
}
for (int i = 1; i < n; i++){
child[0].insert(i);
child[i].insert(0);
par[i] = 0;
}
par[0] = -1;
}
void dfs(int node, int root){
// cout<<node<<sp<<root<<endl;
par[node] = root;
tin[node] = ++cntr;
sz[node] = 1;
for (auto i : child[node]){
if (i == root) continue;
dfs(i, node);
sz[node] += sz[i];
}
tout[node] = cntr;
}
void sub(int node, int root, bitset<MAXN> &b){
b |= adj[node];
for (auto i : child[node]){
if (i == root) continue;
sub(i, node, b);
}
}
int hasEdge(int u, int v) {
cntr = 0;
dfs(0, -1);
adj[u].set(v, 0);
adj[v].set(u, 0);
if (par[u] != v && par[v] != u){
return 0;
}
if (par[v] == u) swap(v, u);
if (sz[u] >= N / 2){
cntr = 0;
dfs(u, -1);
}
if (par[v] == u) swap(v, u);
child[u].erase(v);
child[v].erase(u);
bitset<MAXN> to;
to.reset();
sub(u, v, to);
int parr = -1;
for (int i = 0; i < N; i++){
if (tin[i] >= tin[u] && tout[i] <= tout[u]) continue;
if (to[i] == 1){
parr = i;
break;
}
}
if (parr == -1){
adj[u][v] = 1;
adj[v][u] = 1;
child[u].insert(v);
child[v].insert(u);
return 1;
}
int c = -1;
for (int i = 0; i < N; i++){
if (tin[i] >= tin[u] && tout[i] <= tout[u] && adj[i][parr] == 1){
c = i;
break;
}
}
child[parr].insert(c);
child[c].insert(parr);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2648 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
0 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2648 KB |
Output is correct |
21 |
Correct |
0 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
0 ms |
2396 KB |
Output is correct |
24 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
0 ms |
2392 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2392 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
0 ms |
2396 KB |
Output is correct |
23 |
Correct |
0 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
1 ms |
2396 KB |
Output is correct |
26 |
Correct |
1 ms |
2396 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
29 |
Correct |
1 ms |
2396 KB |
Output is correct |
30 |
Correct |
1 ms |
2396 KB |
Output is correct |
31 |
Correct |
1 ms |
2396 KB |
Output is correct |
32 |
Correct |
1 ms |
2396 KB |
Output is correct |
33 |
Correct |
1 ms |
2396 KB |
Output is correct |
34 |
Correct |
3 ms |
2396 KB |
Output is correct |
35 |
Correct |
3 ms |
2396 KB |
Output is correct |
36 |
Correct |
3 ms |
2396 KB |
Output is correct |
37 |
Correct |
3 ms |
2396 KB |
Output is correct |
38 |
Correct |
3 ms |
2396 KB |
Output is correct |
39 |
Correct |
3 ms |
2396 KB |
Output is correct |
40 |
Correct |
4 ms |
2396 KB |
Output is correct |
41 |
Correct |
3 ms |
2396 KB |
Output is correct |
42 |
Correct |
3 ms |
2396 KB |
Output is correct |
43 |
Correct |
5 ms |
2612 KB |
Output is correct |
44 |
Correct |
3 ms |
2396 KB |
Output is correct |
45 |
Correct |
3 ms |
2396 KB |
Output is correct |
46 |
Correct |
3 ms |
2396 KB |
Output is correct |
47 |
Correct |
3 ms |
2392 KB |
Output is correct |
48 |
Correct |
3 ms |
2396 KB |
Output is correct |
49 |
Correct |
3 ms |
2396 KB |
Output is correct |
50 |
Correct |
3 ms |
2612 KB |
Output is correct |
51 |
Correct |
3 ms |
2396 KB |
Output is correct |
52 |
Correct |
3 ms |
2396 KB |
Output is correct |
53 |
Correct |
3 ms |
2396 KB |
Output is correct |
54 |
Correct |
3 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2392 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
0 ms |
2396 KB |
Output is correct |
16 |
Correct |
0 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
0 ms |
2396 KB |
Output is correct |
21 |
Correct |
0 ms |
2396 KB |
Output is correct |
22 |
Correct |
0 ms |
2396 KB |
Output is correct |
23 |
Correct |
0 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2400 KB |
Output is correct |
25 |
Correct |
1 ms |
2396 KB |
Output is correct |
26 |
Correct |
1 ms |
2392 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
29 |
Correct |
1 ms |
2396 KB |
Output is correct |
30 |
Correct |
1 ms |
2396 KB |
Output is correct |
31 |
Correct |
1 ms |
2396 KB |
Output is correct |
32 |
Correct |
1 ms |
2568 KB |
Output is correct |
33 |
Correct |
1 ms |
2396 KB |
Output is correct |
34 |
Correct |
3 ms |
2396 KB |
Output is correct |
35 |
Correct |
3 ms |
2576 KB |
Output is correct |
36 |
Correct |
3 ms |
2396 KB |
Output is correct |
37 |
Correct |
3 ms |
2396 KB |
Output is correct |
38 |
Correct |
3 ms |
2576 KB |
Output is correct |
39 |
Correct |
3 ms |
2396 KB |
Output is correct |
40 |
Correct |
3 ms |
2396 KB |
Output is correct |
41 |
Correct |
3 ms |
2396 KB |
Output is correct |
42 |
Correct |
4 ms |
2396 KB |
Output is correct |
43 |
Correct |
5 ms |
2396 KB |
Output is correct |
44 |
Correct |
3 ms |
2396 KB |
Output is correct |
45 |
Correct |
3 ms |
2396 KB |
Output is correct |
46 |
Correct |
3 ms |
2392 KB |
Output is correct |
47 |
Correct |
4 ms |
2396 KB |
Output is correct |
48 |
Correct |
3 ms |
2396 KB |
Output is correct |
49 |
Correct |
3 ms |
2392 KB |
Output is correct |
50 |
Correct |
3 ms |
2396 KB |
Output is correct |
51 |
Correct |
3 ms |
2396 KB |
Output is correct |
52 |
Correct |
4 ms |
2396 KB |
Output is correct |
53 |
Correct |
3 ms |
2396 KB |
Output is correct |
54 |
Correct |
3 ms |
2396 KB |
Output is correct |
55 |
Correct |
619 ms |
2940 KB |
Output is correct |
56 |
Correct |
601 ms |
2936 KB |
Output is correct |
57 |
Correct |
638 ms |
2896 KB |
Output is correct |
58 |
Correct |
638 ms |
2896 KB |
Output is correct |
59 |
Correct |
672 ms |
2896 KB |
Output is correct |
60 |
Correct |
658 ms |
2960 KB |
Output is correct |
61 |
Correct |
620 ms |
2940 KB |
Output is correct |
62 |
Correct |
649 ms |
2936 KB |
Output is correct |
63 |
Correct |
622 ms |
2944 KB |
Output is correct |
64 |
Execution timed out |
1014 ms |
2940 KB |
Time limit exceeded |
65 |
Halted |
0 ms |
0 KB |
- |