#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=10005;
vector<int> adj[MX];
int timer=-1;
vector<int> euler;
void dfs(int v, int p) {
euler.push_back(++timer);
for(auto u:adj[v]) {
if(u==p) continue;
dfs(u,v);
}
}
struct DSU {
int par[MX];
int find(int v) {
return par[v]==v?v:par[v]=find(par[v]);
}
bool merge(int u, int v) {
u=find(u),v=find(v);
if(u==v) return false;
par[u]=v;
return true;
}
void prep(int N) {
for(int i=0;i<N;i++) par[i]=i;
}
} ds;
void Joi(int N, int M, int A[], int B[], long long X, int T) {
ds.prep(N);
for(int i=0;i<M;i++) {
int x=A[i],y=B[i];
if(ds.merge(x,y)) {
adj[x].push_back(y);
adj[y].push_back(x);
}
}
dfs(0,-1);
for(int i=0;i<N;i++) {
int k=i%60;
MessageBoard(euler[i],X>>k&1);
}
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=10005;
vector<int> ADJ[MX];
int Timer=-1;
int sz[MX], par[MX], tin[MX], tout[MX];
void DFS(int v, int p) {
tin[v]=++Timer;
sz[v]=1;
par[v]=p;
for(auto u:ADJ[v]) {
if(u==p) continue;
DFS(u,v);
sz[v]+=sz[u];
}
tout[v]=Timer;
}
ll get(int x, int y) {
return y*(1LL<<(tin[x]%60));
}
ll res=0;
void dfs0(int v, int p) {
for(auto u:ADJ[v]) {
if(u==p) continue;
res|=get(u,Move(u));
dfs0(u,v);
Move(v);
}
}
struct DSU {
int par[MX];
int find(int v) {
return par[v]==v?v:par[v]=find(par[v]);
}
bool merge(int u, int v) {
u=find(u),v=find(v);
if(u==v) return false;
par[u]=v;
return true;
}
void prep(int N) {
for(int i=0;i<N;i++) par[i]=i;
}
} DS;
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
DS.prep(N);
for(int i=0;i<M;i++) {
int x=A[i],y=B[i];
if(DS.merge(x,y)) {
ADJ[x].push_back(y);
ADJ[y].push_back(x);
}
}
DFS(0,-1);
int k=V;
while(sz[P]<60) {
P=par[P];
k=Move(P);
}
res|=get(P,k);
dfs0(P,par[P]);
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1296 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
3988 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1300 KB |
Output is correct |
2 |
Correct |
1 ms |
1312 KB |
Output is correct |
3 |
Correct |
1 ms |
1312 KB |
Output is correct |
4 |
Incorrect |
2 ms |
1860 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
3876 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
3832 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |