#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include"Joi.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
vector<ll> g[10010],f[10010];
ll vis[10010],dep[10010];
void dfs1(ll x,ll from,ll d){
if(vis[x])return;
dep[x]=d;
if(from!=-1){
f[x].push_back(from);
f[from].push_back(x);
}
for(auto y:g[x]){
dfs1(y,x,d+1);
}
}
ll col[10010],uma;
void dfs(ll x,ll from){
col[x]=uma; uma++;
for(auto y:f[x])if(y!=from){
if(uma==60)return;
dfs(y,x);
}
}
void Joi(int N,int M,int A[],int B[],ll X,int T){
rep(i,N)vis[i]=0;
rep(i,M){
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
uma=0;
dfs1(0,-1,0);
rep(i,N)col[i]=dep[i]%60;
dfs(0,-1);
for(int i=0;i<N;i++){
MessageBoard(i,!!(X&(1LL<<col[i])));
}
}
//----------------
/*int main(){
}*/
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include"Ioi.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
vector<ll> g[10010],f[10010];
ll vis[10010],dep[10010];
void dfs1(ll x,ll from,ll d){
if(vis[x])return;
dep[x]=d;
if(from!=-1){
f[x].push_back(from);
f[from].push_back(x);
}
for(auto y:g[x]){
dfs1(y,x,d+1);
}
}
ll par[10010];
ll col[10010],uma;
void dfs(ll x,ll from){
par[x]=from;
col[x]=uma; uma++;
for(auto y:f[x])if(y!=from){
if(uma==60)return;
dfs(y,x);
}
}
int ges[60];
bool perf(){
rep(k,60)if(ges[k]!=-1)return 0;
return 1;
}
ll calc(){
ll ans=0;
rep(k,60){
ans+=(1LL<<k)*ges[k];
}
return ans;
}
ll dd(ll x,ll from){
if(from!=-1)ges[col[x]]=Move(x);
for(auto y:f[x])if(y!=from){
if(perf())return calc();
dd(y,x);
Move(x);
}
return -1;
}
ll Ioi(int N,int M,int A[],int B[],int P,int V,int T){
rep(i,N)vis[i]=0;
rep(i,M){
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
uma=0;
dfs1(0,-1,0);
rep(i,N)col[i]=dep[i]%60;
dfs(0,-1);
rep(k,60)ges[k]=-1;
while(P!=0){
ges[col[P]]=V;
if(perf()){
return calc();
}
P=par[P];
V=Move(P);
}
ges[col[0]]=V;
return dd(0,-1);
}
/*int main(){
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
290 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
260 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
261 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
264 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
269 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |