#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int>vi;
#define pb push_back
#define sz(v) (int)v.size()
#define all(x) begin(x),end(x)
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define ROF(i,a,b) for(int i=b-1; i>=a; i--)
//------------------------------------------------//
const int MX=2e4+10;
const int LOG=60;
bitset<LOG>b;
vi nei[MX];
vi par(MX),adj[MX],bit(MX),val(MX);
int cnt=-1;
vi viss(MX,0);
void dfs(int u, int p){
viss[u]=1;
par[u]=p;
bit[u]=++cnt; bit[u]%=LOG;
val[u]=b[bit[u]];
for(int v: nei[u]) if(!viss[v]){
adj[u].pb(v);
dfs(v,u);
}
}
void Joi(int N, int M, int A[], int B[], ll X, int T){
FOR(i,0,M){
int u=A[i],v=B[i];
nei[u].pb(v);
nei[v].pb(u);
}
FOR(i,0,LOG){
b[i]=X%2;
X/=2;
}
dfs(0,0);
FOR(i,0,N) MessageBoard(i,val[i]);
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int>vi;
#define pb push_back
#define sz(v) (int)v.size()
#define all(x) begin(x),end(x)
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define ROF(i,a,b) for(int i=b-1; i>=a; i--)
//------------------------------------------------//
const int MX=2e4+10;
const int LOG=60;
vi nei2[MX];
vi par2(MX),adj2[MX],bit2(MX);
int cnt2=-1;
vi visss(MX,0);
set<int>ss[MX];
void dfs2(int u, int p){
visss[u]=1;
par2[u]=p;
bit2[u]=++cnt2; bit2[u]%=LOG;
for(int v: nei2[u]) if(!visss[v]){
adj2[u].pb(v);
dfs2(v,u);
}
}
vi ans(LOG),vis(MX,0);
set<int>s;
void explore(int u, int x){
vis[u]=1;
s.insert(bit2[u]);
ans[bit2[u]]=x;
if(sz(s)>=LOG) return;
int all=1,none=1;
for(int v: adj2[u]){
if(!vis[v]) all=0;
if(vis[v]) none=0;
}
if(all){
assert(u!=0);
explore(par2[u],Move(par2[u]));
}
else if(none){
explore(adj2[u][0],Move(adj2[u][0]));
}
else{
int idx=-1;
FOR(i,0,sz(adj2[u])) if(vis[adj2[u][i]]){
if(i) idx=i-1;
else{
idx=i;
while(idx<sz(adj2[u]) && vis[adj2[u][idx]]){
idx++;
}
assert(idx<sz(adj2[u]));
}
break;
}
assert(idx!=-1);
explore(adj2[u][idx],Move(adj2[u][idx]));
}
}
ll Ioi(int N, int M, int A[], int B[], int P, int V, int T){
FOR(i,0,M){
int u=A[i],v=B[i];
nei2[u].pb(v);
nei2[v].pb(u);
}
dfs2(0,0);
explore(P,V);
ll x=0;
ROF(i,0,LOG){
x*=2;
x+=ans[i];
}
return x;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4072 KB |
Output is correct |
2 |
Correct |
4 ms |
4068 KB |
Output is correct |
3 |
Correct |
4 ms |
4076 KB |
Output is correct |
4 |
Correct |
4 ms |
4088 KB |
Output is correct |
5 |
Correct |
3 ms |
4072 KB |
Output is correct |
6 |
Correct |
4 ms |
4072 KB |
Output is correct |
7 |
Correct |
4 ms |
4084 KB |
Output is correct |
8 |
Correct |
4 ms |
4088 KB |
Output is correct |
9 |
Correct |
4 ms |
4076 KB |
Output is correct |
10 |
Correct |
3 ms |
4072 KB |
Output is correct |
11 |
Correct |
7 ms |
4508 KB |
Output is correct |
12 |
Correct |
3 ms |
4072 KB |
Output is correct |
13 |
Correct |
4 ms |
4080 KB |
Output is correct |
14 |
Correct |
5 ms |
4076 KB |
Output is correct |
15 |
Correct |
4 ms |
4076 KB |
Output is correct |
16 |
Correct |
4 ms |
4076 KB |
Output is correct |
17 |
Correct |
4 ms |
4088 KB |
Output is correct |
18 |
Correct |
4 ms |
4076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
7352 KB |
Output is correct |
2 |
Correct |
28 ms |
7324 KB |
Output is correct |
3 |
Correct |
31 ms |
7280 KB |
Output is correct |
4 |
Correct |
19 ms |
5804 KB |
Output is correct |
5 |
Correct |
18 ms |
6616 KB |
Output is correct |
6 |
Correct |
17 ms |
6316 KB |
Output is correct |
7 |
Correct |
17 ms |
6312 KB |
Output is correct |
8 |
Correct |
18 ms |
6292 KB |
Output is correct |
9 |
Correct |
19 ms |
6392 KB |
Output is correct |
10 |
Correct |
16 ms |
5840 KB |
Output is correct |
11 |
Correct |
16 ms |
5816 KB |
Output is correct |
12 |
Correct |
18 ms |
5532 KB |
Output is correct |
13 |
Correct |
17 ms |
5540 KB |
Output is correct |
14 |
Correct |
19 ms |
5672 KB |
Output is correct |
15 |
Correct |
18 ms |
6040 KB |
Output is correct |
16 |
Correct |
17 ms |
6036 KB |
Output is correct |
17 |
Correct |
20 ms |
5872 KB |
Output is correct |
18 |
Correct |
19 ms |
5828 KB |
Output is correct |
19 |
Correct |
20 ms |
5736 KB |
Output is correct |
20 |
Correct |
15 ms |
6404 KB |
Output is correct |
21 |
Correct |
15 ms |
6388 KB |
Output is correct |
22 |
Correct |
18 ms |
6140 KB |
Output is correct |
23 |
Correct |
19 ms |
6344 KB |
Output is correct |
24 |
Correct |
18 ms |
6060 KB |
Output is correct |
25 |
Correct |
18 ms |
6152 KB |
Output is correct |
26 |
Correct |
18 ms |
6180 KB |
Output is correct |
27 |
Correct |
19 ms |
6324 KB |
Output is correct |
28 |
Correct |
18 ms |
6240 KB |
Output is correct |
29 |
Correct |
18 ms |
6096 KB |
Output is correct |
30 |
Correct |
17 ms |
6028 KB |
Output is correct |
31 |
Correct |
4 ms |
4072 KB |
Output is correct |
32 |
Correct |
4 ms |
3976 KB |
Output is correct |
33 |
Correct |
4 ms |
4076 KB |
Output is correct |
34 |
Correct |
4 ms |
4072 KB |
Output is correct |
35 |
Correct |
3 ms |
4072 KB |
Output is correct |
36 |
Correct |
4 ms |
4072 KB |
Output is correct |
37 |
Correct |
5 ms |
4072 KB |
Output is correct |
38 |
Correct |
3 ms |
4072 KB |
Output is correct |
39 |
Correct |
4 ms |
4072 KB |
Output is correct |
40 |
Correct |
3 ms |
4068 KB |
Output is correct |
41 |
Correct |
3 ms |
4080 KB |
Output is correct |
42 |
Correct |
4 ms |
4216 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4072 KB |
Output is correct |
2 |
Correct |
4 ms |
4072 KB |
Output is correct |
3 |
Correct |
4 ms |
4076 KB |
Output is correct |
4 |
Correct |
6 ms |
4496 KB |
Output is correct |
5 |
Correct |
5 ms |
4528 KB |
Output is correct |
6 |
Correct |
6 ms |
4480 KB |
Output is correct |
7 |
Correct |
5 ms |
4484 KB |
Output is correct |
8 |
Correct |
6 ms |
4492 KB |
Output is correct |
9 |
Correct |
15 ms |
7324 KB |
Output is correct |
10 |
Correct |
16 ms |
7344 KB |
Output is correct |
11 |
Correct |
15 ms |
7308 KB |
Output is correct |
12 |
Correct |
3 ms |
4080 KB |
Output is correct |
13 |
Correct |
3 ms |
4072 KB |
Output is correct |
14 |
Correct |
3 ms |
3968 KB |
Output is correct |
15 |
Correct |
3 ms |
4072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
7344 KB |
Output is correct |
2 |
Partially correct |
28 ms |
7368 KB |
Partially correct |
3 |
Correct |
28 ms |
7392 KB |
Output is correct |
4 |
Correct |
18 ms |
5852 KB |
Output is correct |
5 |
Correct |
19 ms |
6816 KB |
Output is correct |
6 |
Correct |
23 ms |
6316 KB |
Output is correct |
7 |
Correct |
20 ms |
6316 KB |
Output is correct |
8 |
Correct |
18 ms |
6056 KB |
Output is correct |
9 |
Correct |
17 ms |
6208 KB |
Output is correct |
10 |
Correct |
19 ms |
5648 KB |
Output is correct |
11 |
Correct |
19 ms |
5592 KB |
Output is correct |
12 |
Correct |
16 ms |
5596 KB |
Output is correct |
13 |
Correct |
17 ms |
5528 KB |
Output is correct |
14 |
Correct |
20 ms |
5660 KB |
Output is correct |
15 |
Partially correct |
17 ms |
6060 KB |
Partially correct |
16 |
Partially correct |
18 ms |
6020 KB |
Partially correct |
17 |
Correct |
17 ms |
5796 KB |
Output is correct |
18 |
Correct |
19 ms |
5824 KB |
Output is correct |
19 |
Correct |
17 ms |
5880 KB |
Output is correct |
20 |
Correct |
15 ms |
6316 KB |
Output is correct |
21 |
Correct |
15 ms |
6256 KB |
Output is correct |
22 |
Correct |
18 ms |
6220 KB |
Output is correct |
23 |
Correct |
18 ms |
6060 KB |
Output is correct |
24 |
Correct |
17 ms |
6068 KB |
Output is correct |
25 |
Correct |
17 ms |
6328 KB |
Output is correct |
26 |
Correct |
19 ms |
6156 KB |
Output is correct |
27 |
Correct |
18 ms |
6320 KB |
Output is correct |
28 |
Correct |
19 ms |
6040 KB |
Output is correct |
29 |
Correct |
17 ms |
6008 KB |
Output is correct |
30 |
Correct |
17 ms |
6040 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
7336 KB |
Output is correct |
2 |
Correct |
30 ms |
7360 KB |
Output is correct |
3 |
Correct |
28 ms |
7400 KB |
Output is correct |
4 |
Incorrect |
18 ms |
5788 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |