#include "bits/stdc++.h"
using namespace std;
#include "Joi.h"
const int N = 1e4 + 5;
vector<int> G[N], tt, ee[N];
int used[N], in[N], cnt = 1;
bitset<60> gg[60], uu;
void dfs(int u){
used[u] = 1;
for(auto x : G[u]){
if(used[x]) continue;
ee[u].push_back(x);
ee[x].push_back(u);
if(cnt < 60){
tt.push_back(x);
in[x] = cnt++;
gg[in[u]][in[x]] = gg[in[x]][in[u]] = 1;
dfs(x);
} else {
int par = -1;
bitset<60> tmp;
for(int i=0;i<60;i++){
if(i == in[u]) continue;
int cc = 0;
for(int j=0;j<60;j++) cc += gg[i][j];
if(cc != 1) continue;
tmp = gg[i], par = tt[i];
for(int j=0;j<60;j++) gg[i][j] = gg[j][i] = 0;
tt[i] = x;
gg[in[u]][i] = gg[i][in[u]] = 1;
in[x] = i;
break;
}
dfs(x);
assert(~par);
for(int j=0;j<60;j++){
gg[in[par]][j] = gg[j][in[par]] = tmp[j];
} tt[in[par]] = u;
}
}
}
void Joi(int n, int m, int a[], int b[], long long x, int t){
for(int i=0;i<m;i++){
G[a[i]].push_back(b[i]);
G[b[i]].push_back(a[i]);
} for(int i=0;i<n;i++){
sort(G[i].begin(), G[i].end());
}
tt.push_back(0);
memset(in, -1, sizeof in);
in[0] = 0; dfs(0);
//~ for(int i=0;i<n;i++) cout<<in[i]<<" ";
//~ cout<<"\n";
for(int i=0;i<n;i++){
assert(~in[i]);
MessageBoard(i, x >> in[i] & 1);
}
}
#include "bits/stdc++.h"
using namespace std;
#include "Ioi.h"
const int N = 1e4 + 5;
vector<int> G[N], tt, ee[N];
int used[N], in[N], cnt = 1;
bitset<60> gg[60], uu;
void dfs(int u){
used[u] = 1;
for(auto x : G[u]){
if(used[x]) continue;
ee[u].push_back(x);
ee[x].push_back(u);
if(cnt < 60){
tt.push_back(x);
in[x] = cnt++;
gg[in[u]][in[x]] = gg[in[x]][in[u]] = 1;
dfs(x);
} else {
int par = -1;
bitset<60> tmp;
for(int i=0;i<60;i++){
if(i == in[u]) continue;
int cc = 0;
for(int j=0;j<60;j++) cc += gg[i][j];
if(cc != 1) continue;
tmp = gg[i], par = tt[i];
for(int j=0;j<60;j++) gg[i][j] = gg[j][i] = 0;
tt[i] = x;
gg[in[u]][i] = gg[i][in[u]] = 1;
in[x] = i;
break;
}
dfs(x);
assert(~par);
for(int j=0;j<60;j++){
gg[in[par]][j] = gg[j][in[par]] = tmp[j];
} tt[in[par]] = u;
}
}
}
long long Ioi(int n, int m, int a[], int b[], int p, int v, int t){
for(int i=0;i<m;i++){
G[a[i]].push_back(b[i]);
G[b[i]].push_back(a[i]);
} for(int i=0;i<n;i++){
sort(G[i].begin(), G[i].end());
}
tt.push_back(0);
memset(in, -1, sizeof in);
in[0] = 0; dfs(0);
//~ for(int i=0;i<n;i++) cout<<in[i]<<" ";
//~ cout<<"\n";
memset(used, 0, sizeof used);
long long x = 0;
function<void(int)> go = [&](int u){
used[u] = uu[in[u]] = 1;
if(v) x |= (1ll << in[u]);
for(auto x : ee[u]){
if(used[x] || uu[in[x]]) continue;
v = Move(x), go(x),
v = Move(u);
}
};
go(p);
for(int i=0;i<60;i++) assert(uu[i]);
return x;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1640 KB |
Output is correct |
2 |
Runtime error |
3 ms |
2408 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
21 ms |
4344 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1640 KB |
Output is correct |
2 |
Correct |
1 ms |
1644 KB |
Output is correct |
3 |
Correct |
2 ms |
1636 KB |
Output is correct |
4 |
Correct |
9 ms |
2308 KB |
Output is correct |
5 |
Correct |
11 ms |
2308 KB |
Output is correct |
6 |
Correct |
10 ms |
2308 KB |
Output is correct |
7 |
Correct |
8 ms |
2292 KB |
Output is correct |
8 |
Correct |
12 ms |
2320 KB |
Output is correct |
9 |
Correct |
49 ms |
5428 KB |
Output is correct |
10 |
Correct |
52 ms |
5452 KB |
Output is correct |
11 |
Correct |
54 ms |
5460 KB |
Output is correct |
12 |
Correct |
2 ms |
1640 KB |
Output is correct |
13 |
Correct |
2 ms |
1640 KB |
Output is correct |
14 |
Correct |
2 ms |
1640 KB |
Output is correct |
15 |
Correct |
2 ms |
1648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
23 ms |
4360 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
26 ms |
4272 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |