#include<bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define pp pop_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
void debug2(){cerr<<"\n";}
template<typename H, typename... T>
void debug2(H h, T... t){
cerr<<h;
if(sizeof...(t))cerr<<", ";
debug2(t...);
}
#define deb(x) cerr<<#x<<" = ";debug2(x);
mt19937 rng2(chrono::high_resolution_clock().now().time_since_epoch().count());
const int NN2=1e4+5;
#include "Joi.h"
vector<int> bit2;
vi E2[NN2];
int vis2[NN2], czy2[NN2], kol2[NN2];
vector<pii> todo2;
int ddfs2(int v){
int m=0;
vis2[v]=2;
for(int u:E2[v]){
if(czy2[u] && vis2[u]!=2){
m=max(m, ddfs2(u));
}
}
m++;
todo2.eb(-m, v);
return m;
}
int ddfs(int v){
int sz=0;
vis2[v]=1;
for(int u:E2[v]){
if(!vis2[u]){
sz+=ddfs(u);
}
}
czy2[v]=1;
sz++;
if(sz>=60){
ddfs2(v);
sort(all(todo2));
for(int i=0; i<60; i++)kol2[todo2[i].nd]=i;
for(pii i:todo2)czy2[i.nd]=0;
sz=0;
}
return sz;
}
void Joi(int n, int m, int A[], int B[], long long X, int T) {
for(int i=0; i<m; i++){
E2[A[i]].pb(B[i]);
E2[B[i]].pb(A[i]);
}
for(int i=0; i<60; i++)bit2.pb(X&1), X/=2;
ddfs(1);
for(int i=0; i<n; i++){
MessageBoard(i, bit2[kol2[i]]);
}
}
#include<bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define pp pop_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
void debug(){cerr<<"\n";}
template<typename H, typename... T>
void debug(H h, T... t){
cerr<<h;
if(sizeof...(t))cerr<<", ";
debug(t...);
}
#define deb(x) cerr<<#x<<" = ";debug(x);
mt19937 rng(chrono::high_resolution_clock().now().time_since_epoch().count());
const int NN=1e4+5, INF=1e9+5;
#include "Ioi.h"
int bit[60];
vi E[NN];
int vis[NN], czy[NN], kol[NN], par[NN];
vector<pii> todo;
int pp;
int dfs2(int v){
int m=0;
vis[v]=2;
for(int u:E[v]){
if(czy[u] && vis[u]!=2){
m=max(m, dfs2(u));
}
}
m++;
todo.eb(-m, v);
return m;
}
void move(int x){
int t=Move(x);
bit[kol[x]]=t;
}
void dfs3(int v){
vis[v]=2;
for(int u:E[v]){
if(vis[u]==3){
move(u);
dfs3(u);
move(v);
}
}
}
int dfs(int v){
int sz=0;
vis[v]=1;
for(int u:E[v]){
if(!vis[u]){
par[u]=v;
sz+=dfs(u);
}
}
czy[v]=1;
sz++;
if(sz>=60){
dfs2(v);
sort(all(todo));
for(int i=0; i<60; i++)kol[todo[i].nd]=i, vis[todo[i].nd]=3;
if(czy[pp]){
while(vis[pp]!=3)move(par[pp]), pp=par[pp];
dfs3(pp);
}
for(pii i:todo)czy[i.nd]=0;
sz=0;
}
return sz;
}
long long Ioi(int n, int m, int A[], int B[], int P, int V, int T) {
for(int i=0; i<m; i++){
E[A[i]].pb(B[i]);
E[B[i]].pb(A[i]);
}
pp=P;
dfs(1);
bit[kol[P]]=V;
ll x=0;
for(int i=59; i>=0; i--)x=x+x+bit[i];
return x;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1032 KB |
Output is correct |
2 |
Correct |
1 ms |
1028 KB |
Output is correct |
3 |
Correct |
2 ms |
1288 KB |
Output is correct |
4 |
Correct |
1 ms |
1036 KB |
Output is correct |
5 |
Incorrect |
2 ms |
1120 KB |
Wrong Answer [7] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
147 ms |
5200 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1028 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
90 ms |
4872 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
156 ms |
5128 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |