#include "Joi.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define st first
#define nd second
#define pb push_back
#define MAX 20005
#define sz(x) ((int)x.size())
#define pw(x) (1LL<<(x))
static int Time;
static int beg[MAX];
static bool Bit[MAX],vis[MAX];
static vector<int> v[MAX];
static void createbits(ll x) {
for(int i=0;i<60;i++) Bit[i]=((x>>i)&1);
}
static void dfs(int node) {
vis[node]=true;
beg[node]=Time++;
MessageBoard(node,Bit[beg[node]%60]);
for(int i:v[node]) {
if(vis[i]) continue ;
dfs(i);
}
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
createbits(X);
for(int i=0;i<M;i++) {
v[A[i]].pb(B[i]);
v[B[i]].pb(A[i]);
}
dfs(0);
}
#include "Ioi.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define st first
#define nd second
#define pb push_back
#define MAX 20005
#define sz(x) ((int) x.size())
#define pw(x) (1LL<<(x))
static int sub[MAX],Par[MAX],beg[MAX];
static int Time,total,V,P;
static ll X;
static vector<int> v[MAX],v2[MAX];
static bool vis[MAX];
static void dfs2(int node) {
total++;
X|=V*pw(beg[node]%60);
for(int i:v2[node]) {
if(total==60) continue ;
V=Move(i);
dfs2(i);
if(total<60) V=Move(node);
}
}
static void solve() {
total=1;
while(1) {
if(sub[P]>=60) break ;
P=Par[P];
V=Move(P);
}
dfs2(P);
}
static void dfs(int node,int ata) {
vis[node]=true;
sub[node]=1;
beg[node]=Time++;
Par[node]=ata;
if(~ata) v2[ata].pb(node);
for(int i:v[node]) {
if(vis[i]) continue ;
dfs(i,node);
sub[node]+=sub[i];
}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
for(int i=0;i<M;i++) {
v[A[i]].pb(B[i]);
v[B[i]].pb(A[i]);
}
::P=P;
::V=V;
dfs(0,-1);
solve();
return X;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2276 KB |
Output is correct |
2 |
Incorrect |
6 ms |
2776 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
5276 KB |
Output is correct |
2 |
Incorrect |
40 ms |
6352 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
6448 KB |
Output is correct |
2 |
Correct |
6 ms |
6448 KB |
Output is correct |
3 |
Correct |
7 ms |
6448 KB |
Output is correct |
4 |
Correct |
8 ms |
6448 KB |
Output is correct |
5 |
Correct |
10 ms |
6448 KB |
Output is correct |
6 |
Correct |
9 ms |
6448 KB |
Output is correct |
7 |
Incorrect |
10 ms |
6448 KB |
Wrong Answer [7] |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
6556 KB |
Output is correct |
2 |
Incorrect |
51 ms |
6664 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
6664 KB |
Output is correct |
2 |
Incorrect |
39 ms |
6664 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |