#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 long long res = 0;
static long long cal = 0;
static int sub[maxn] , h[maxn];
static long long can[maxn];
static vector<int> adj[maxn];
static vector<int> child[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){
sub[u] = 1;
for(int c : adj[u]){
if(c != par){
child[u].push_back(c);
h[c] = h[u] + 1;
DFS(c , u);
sub[u] += sub[c];
}
}
};
function<void(int,int)> DFS3 = [&](int u , int par){
id[u] = nTime;
can[u] = (1ll << nTime);
nTime = (nTime + 1) % 60;
if(child[u].empty())return;
stable_sort(child[u].begin(),child[u].end(),[&](const int x , const int y){
return h[x] > h[y];
});
for(int c : child[u]){
if(c != par){
DFS3(c , u);
can[u] |= can[c];
}
}
};
DFS(N / 2 , -1);
DFS3(N / 2 , -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 int sub[maxn] , h[maxn];
static long long can[maxn];
static int p[maxn];
static vector<int> adj[maxn];
static vector<int> child[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){
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){
sub[u] = 1;
for(int c : adj[u]){
if(c != par){
child[u].push_back(c);
h[c] = h[u] + 1;
DFS(c , u);
sub[u] += sub[c];
}
}
};
function<void(int,int)> DFS3 = [&](int u , int par){
id[u] = nTime;
can[u] = (1ll << nTime);
nTime = (nTime + 1) % 60;
if(child[u].empty())return;
stable_sort(child[u].begin(),child[u].end(),[&](const int x , const int y){
return h[x] > h[y];
});
for(int c : child[u]){
p[c] = u;
DFS3(c , u);
can[u] |= can[c];
}
};
DFS(N / 2 , -1);
DFS3(N / 2 , -1);
function<void(int)> DFS2 = [&](int u){
cal |= (1ll << id[u]);
if(V)res |= (1ll << id[u]);
for(int c : child[u]){
if(__builtin_popcountll(cal) == 60)return;
if((~cal) & can[c]){
V = Move(c);
DFS2(c);
V = Move(u);
}
}
};
function<void(int)> DFS1 = [&](int u){
cal |= (1ll << id[u]);
if(V)res |= (1ll << id[u]);
if(child[u].empty())return;
int first = -1;
for(int i = 0 ; i < (int)child[u].size() ; ++i){
if(__builtin_popcountll(cal) == 60)return;
int c = child[u][i];
if((~cal) & can[c]){
if(first != -1){
V = Move(c);
DFS2(c);
V = Move(u);
}
else{
first = c;
}
}
}
if((~cal) & can[first]){
V = Move(first);
DFS1(first);
}
};
while(sub[P] < 60){
cal |= (1ll << id[P]);
if(V)res |= (1ll << id[P]);
V = Move(p[P]);
P = p[P];
}
DFS1(P);
return res;
}
Compilation message
Joi.cpp: In function 'void Joi(int, int, int*, int*, long long int, int)':
Joi.cpp:10:22: warning: unused variable 'res' [-Wunused-variable]
static long long res = 0;
^~~
Joi.cpp:11:22: warning: unused variable 'cal' [-Wunused-variable]
static long long cal = 0;
^~~
Joi.cpp: At global scope:
Joi.cpp:11:22: warning: 'cal' defined but not used [-Wunused-variable]
Joi.cpp:10:22: warning: 'res' defined but not used [-Wunused-variable]
static long long res = 0;
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1780 KB |
Output is correct |
2 |
Correct |
6 ms |
2004 KB |
Output is correct |
3 |
Correct |
6 ms |
1788 KB |
Output is correct |
4 |
Correct |
6 ms |
2256 KB |
Output is correct |
5 |
Correct |
6 ms |
1788 KB |
Output is correct |
6 |
Correct |
5 ms |
1916 KB |
Output is correct |
7 |
Correct |
6 ms |
1788 KB |
Output is correct |
8 |
Correct |
5 ms |
1924 KB |
Output is correct |
9 |
Correct |
6 ms |
1924 KB |
Output is correct |
10 |
Correct |
5 ms |
1780 KB |
Output is correct |
11 |
Correct |
9 ms |
2116 KB |
Output is correct |
12 |
Correct |
5 ms |
1780 KB |
Output is correct |
13 |
Correct |
6 ms |
1916 KB |
Output is correct |
14 |
Correct |
6 ms |
1916 KB |
Output is correct |
15 |
Correct |
6 ms |
1916 KB |
Output is correct |
16 |
Correct |
6 ms |
1916 KB |
Output is correct |
17 |
Correct |
6 ms |
1928 KB |
Output is correct |
18 |
Correct |
6 ms |
2172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
4864 KB |
Output is correct |
2 |
Correct |
36 ms |
5060 KB |
Output is correct |
3 |
Correct |
36 ms |
5056 KB |
Output is correct |
4 |
Correct |
29 ms |
4344 KB |
Output is correct |
5 |
Correct |
28 ms |
5792 KB |
Output is correct |
6 |
Correct |
26 ms |
5016 KB |
Output is correct |
7 |
Correct |
25 ms |
5088 KB |
Output is correct |
8 |
Correct |
26 ms |
4896 KB |
Output is correct |
9 |
Correct |
27 ms |
4820 KB |
Output is correct |
10 |
Correct |
20 ms |
4124 KB |
Output is correct |
11 |
Correct |
20 ms |
4132 KB |
Output is correct |
12 |
Correct |
22 ms |
3968 KB |
Output is correct |
13 |
Correct |
23 ms |
4052 KB |
Output is correct |
14 |
Correct |
23 ms |
4116 KB |
Output is correct |
15 |
Correct |
25 ms |
4492 KB |
Output is correct |
16 |
Correct |
25 ms |
4636 KB |
Output is correct |
17 |
Correct |
25 ms |
4256 KB |
Output is correct |
18 |
Correct |
24 ms |
4188 KB |
Output is correct |
19 |
Correct |
25 ms |
4248 KB |
Output is correct |
20 |
Correct |
19 ms |
4640 KB |
Output is correct |
21 |
Correct |
19 ms |
4732 KB |
Output is correct |
22 |
Correct |
25 ms |
5052 KB |
Output is correct |
23 |
Correct |
25 ms |
5120 KB |
Output is correct |
24 |
Correct |
25 ms |
5144 KB |
Output is correct |
25 |
Correct |
25 ms |
5276 KB |
Output is correct |
26 |
Correct |
25 ms |
5232 KB |
Output is correct |
27 |
Correct |
25 ms |
4896 KB |
Output is correct |
28 |
Correct |
25 ms |
4888 KB |
Output is correct |
29 |
Correct |
23 ms |
4616 KB |
Output is correct |
30 |
Correct |
25 ms |
5008 KB |
Output is correct |
31 |
Correct |
6 ms |
1876 KB |
Output is correct |
32 |
Correct |
7 ms |
2180 KB |
Output is correct |
33 |
Correct |
6 ms |
1952 KB |
Output is correct |
34 |
Correct |
5 ms |
2008 KB |
Output is correct |
35 |
Correct |
6 ms |
1780 KB |
Output is correct |
36 |
Correct |
4 ms |
2036 KB |
Output is correct |
37 |
Correct |
6 ms |
1948 KB |
Output is correct |
38 |
Correct |
6 ms |
1984 KB |
Output is correct |
39 |
Correct |
6 ms |
1916 KB |
Output is correct |
40 |
Correct |
6 ms |
2000 KB |
Output is correct |
41 |
Correct |
6 ms |
1908 KB |
Output is correct |
42 |
Correct |
6 ms |
1920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1780 KB |
Output is correct |
2 |
Correct |
6 ms |
1780 KB |
Output is correct |
3 |
Correct |
6 ms |
1916 KB |
Output is correct |
4 |
Correct |
8 ms |
2472 KB |
Output is correct |
5 |
Correct |
8 ms |
2336 KB |
Output is correct |
6 |
Correct |
8 ms |
2508 KB |
Output is correct |
7 |
Correct |
8 ms |
2464 KB |
Output is correct |
8 |
Correct |
7 ms |
2380 KB |
Output is correct |
9 |
Correct |
20 ms |
5528 KB |
Output is correct |
10 |
Correct |
20 ms |
5460 KB |
Output is correct |
11 |
Correct |
20 ms |
5536 KB |
Output is correct |
12 |
Correct |
4 ms |
1828 KB |
Output is correct |
13 |
Correct |
5 ms |
1784 KB |
Output is correct |
14 |
Correct |
5 ms |
1780 KB |
Output is correct |
15 |
Correct |
4 ms |
1840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
34 ms |
4864 KB |
Partially correct |
2 |
Partially correct |
34 ms |
4992 KB |
Partially correct |
3 |
Partially correct |
34 ms |
4972 KB |
Partially correct |
4 |
Correct |
24 ms |
4256 KB |
Output is correct |
5 |
Partially correct |
26 ms |
5408 KB |
Partially correct |
6 |
Correct |
25 ms |
5272 KB |
Output is correct |
7 |
Partially correct |
25 ms |
5056 KB |
Partially correct |
8 |
Correct |
25 ms |
5316 KB |
Output is correct |
9 |
Correct |
25 ms |
4772 KB |
Output is correct |
10 |
Correct |
19 ms |
4124 KB |
Output is correct |
11 |
Correct |
20 ms |
4128 KB |
Output is correct |
12 |
Correct |
23 ms |
3968 KB |
Output is correct |
13 |
Correct |
23 ms |
4020 KB |
Output is correct |
14 |
Partially correct |
23 ms |
3992 KB |
Partially correct |
15 |
Partially correct |
24 ms |
4624 KB |
Partially correct |
16 |
Correct |
25 ms |
4248 KB |
Output is correct |
17 |
Correct |
24 ms |
4248 KB |
Output is correct |
18 |
Correct |
24 ms |
4256 KB |
Output is correct |
19 |
Correct |
24 ms |
4256 KB |
Output is correct |
20 |
Correct |
20 ms |
4848 KB |
Output is correct |
21 |
Correct |
19 ms |
4736 KB |
Output is correct |
22 |
Partially correct |
26 ms |
5196 KB |
Partially correct |
23 |
Correct |
25 ms |
5016 KB |
Output is correct |
24 |
Partially correct |
25 ms |
5204 KB |
Partially correct |
25 |
Partially correct |
25 ms |
4760 KB |
Partially correct |
26 |
Partially correct |
25 ms |
5220 KB |
Partially correct |
27 |
Correct |
25 ms |
5016 KB |
Output is correct |
28 |
Correct |
25 ms |
4896 KB |
Output is correct |
29 |
Partially correct |
24 ms |
4808 KB |
Partially correct |
30 |
Partially correct |
23 ms |
4768 KB |
Partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
4996 KB |
Output is correct |
2 |
Incorrect |
34 ms |
4868 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |