#include<bits/stdc++.h>
#include "Joi.h"
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
const int maxn=1e4+9;
vector<int>a[maxn];
vector<int>g[maxn];
int in[maxn],tme=0,par[maxn],out[maxn];
bool vis[maxn];
void dfs(int u){
vis[u]=1;
in[u]=++tme;
for (auto v:a[u]){
if (!vis[v]){
par[v]=u;
g[u].pb(v);
g[v].pb(u);
dfs(v);
}
}
out[u]=tme;
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
for1(i,0,M-1){
a[A[i]].pb(B[i]);
a[B[i]].pb(A[i]);
}
for1(i,0,N-1)sort(all(a[i]));
dfs(0);
for1(i,0,N-1){
long long bit=(in[i]-1)%60;
MessageBoard(i,(X>>bit&1ll));
}
}
#include<bits/stdc++.h>
#include "Ioi.h"
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
const int maxn=1e4+9;
vector<int>a[maxn];
vector<int>g[maxn];
int in[maxn],tme=0,par[maxn],out[maxn];
bool vis[maxn];
void dfs(int u){
vis[u]=1;
in[u]=++tme;
for (auto v:a[u]){
if (!vis[v]){
par[v]=u;
g[u].pb(v);
g[v].pb(u);
dfs(v);
}
}
out[u]=tme;
}
int dem=0;
bool bit[maxn];
bool revis[maxn];
vector<int>rg[maxn];
void redfs(int u){
dem++;
revis[u]=1;
if (dem==60)return;
for (auto v:g[u]){
if (dem==60)return;
if (!revis[v]){
rg[u].pb(v);
rg[v].pb(u);
//cerr<<u<<" "<<v<<'\n';
redfs(v);
if (dem==60)return;
}
}
}
void solve(int u){
revis[u]=1;
for (auto v:rg[u]){
if (!revis[v]){
bit[v]=Move(v);
solve(v);
bit[u]=Move(u);
}
}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
for1(i,0,N-1){
a[i].clear(),g[i].clear();
vis[i]=0;
}
for1(i,0,M-1){
a[A[i]].pb(B[i]);
a[B[i]].pb(A[i]);
}
for1(i,0,N-1)sort(all(a[i]));
tme=0;
dfs(0);
for1(i,0,N-1)revis[i]=0;
redfs(P);
for1(i,0,N-1)revis[i]=0;
solve(P);
long long ans=0;
for1(i,0,N-1){
if (revis[i]){
long long bb=(in[i]-1)%60;
if (bit[i])ans+=(1<<bb);
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2068 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
6420 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2080 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
6188 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
6360 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |