#include "Joi.h"
#include<bits/stdc++.h>
using namespace std;
void Joi(int N, int M, int A[], int B[], long long X, int T) {
const static int maxn = 1e4 + 5;
static int lab[maxn];
static int nTime = 0;
static int id[maxn];
static vector<int> adj[maxn];
fill_n(lab,maxn,-1);
function<int(int)> FindLab = [&](int u){
return lab[u] < 0 ? u : lab[u] = FindLab(lab[u]);
};
for(int i = 0 ; i < M ; ++i){
int s = FindLab(A[i]);
int d = FindLab(B[i]);
if(s != d){
if(lab[s] > lab[d])swap(s , d);
lab[s] += lab[d];
lab[d] = s;
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
}
function<void(int,int)> DFS = [&](int u , int par){
id[u] = nTime;
nTime = (nTime + 1) % 60;
for(int c : adj[u]){
if(c != par){
DFS(c , u);
}
}
};
DFS(0 , -1);
for(int i = 0 ; i < N ; ++i){
MessageBoard(i , (X >> id[i]) & 1);
}
}
#include "Ioi.h"
#include<bits/stdc++.h>
using namespace std;
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
const static int maxn = 1e4 + 5;
static int lab[maxn];
static int nTime = 0;
static int id[maxn];
static long long res = 0;
static long long cal = 0;
static vector<int> adj[maxn];
fill_n(lab,maxn,-1);
function<int(int)> FindLab = [&](int u){
return lab[u] < 0 ? u : lab[u] = FindLab(lab[u]);
};
for(int i = 0 ; i < M ; ++i){
int s = FindLab(A[i]);
int d = FindLab(B[i]);
if(s != d){
if(lab[s] > lab[d])swap(s , d);
lab[s] += lab[d];
lab[d] = s;
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
}
function<void(int,int)> DFS = [&](int u , int par){
id[u] = nTime;
nTime = (nTime + 1) % 60;
for(int c : adj[u]){
if(c != par){
DFS(c , u);
}
}
};
DFS(0 , -1);
function<void(int,int)> DFS1 = [&](int u , int par){
cal |= (1ll << id[u]);
if(V)res |= (1ll << id[u]);
for(int c : adj[u]){
if(c != par && !((cal >> id[c]) & 1)){
V = Move(c);
DFS1(c , u);
V = Move(u);
}
}
};
DFS1(P , -1);
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1396 KB |
Output is correct |
2 |
Correct |
5 ms |
1396 KB |
Output is correct |
3 |
Incorrect |
4 ms |
1276 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
3712 KB |
Output is correct |
2 |
Incorrect |
30 ms |
3840 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1396 KB |
Output is correct |
2 |
Correct |
4 ms |
1460 KB |
Output is correct |
3 |
Correct |
4 ms |
1396 KB |
Output is correct |
4 |
Correct |
6 ms |
1824 KB |
Output is correct |
5 |
Correct |
7 ms |
1912 KB |
Output is correct |
6 |
Correct |
7 ms |
1832 KB |
Output is correct |
7 |
Correct |
7 ms |
1916 KB |
Output is correct |
8 |
Correct |
7 ms |
1916 KB |
Output is correct |
9 |
Correct |
17 ms |
4280 KB |
Output is correct |
10 |
Correct |
17 ms |
4120 KB |
Output is correct |
11 |
Correct |
17 ms |
4248 KB |
Output is correct |
12 |
Correct |
4 ms |
1396 KB |
Output is correct |
13 |
Correct |
4 ms |
1396 KB |
Output is correct |
14 |
Correct |
5 ms |
1268 KB |
Output is correct |
15 |
Correct |
4 ms |
1276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
3840 KB |
Output is correct |
2 |
Correct |
30 ms |
4108 KB |
Output is correct |
3 |
Correct |
30 ms |
3820 KB |
Output is correct |
4 |
Correct |
20 ms |
2840 KB |
Output is correct |
5 |
Correct |
22 ms |
3872 KB |
Output is correct |
6 |
Correct |
20 ms |
3460 KB |
Output is correct |
7 |
Incorrect |
20 ms |
3360 KB |
Wrong Answer [7] |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
3848 KB |
Output is correct |
2 |
Correct |
28 ms |
3712 KB |
Output is correct |
3 |
Correct |
28 ms |
3712 KB |
Output is correct |
4 |
Correct |
20 ms |
3168 KB |
Output is correct |
5 |
Correct |
20 ms |
4024 KB |
Output is correct |
6 |
Correct |
19 ms |
3352 KB |
Output is correct |
7 |
Correct |
20 ms |
3360 KB |
Output is correct |
8 |
Correct |
20 ms |
3608 KB |
Output is correct |
9 |
Correct |
20 ms |
3480 KB |
Output is correct |
10 |
Correct |
18 ms |
3100 KB |
Output is correct |
11 |
Correct |
19 ms |
3100 KB |
Output is correct |
12 |
Correct |
19 ms |
2944 KB |
Output is correct |
13 |
Incorrect |
19 ms |
2944 KB |
Wrong Answer [7] |
14 |
Halted |
0 ms |
0 KB |
- |