#include "Joi.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
namespace {
const int N = 10000;
const int k = 60;
int n, m;
vector<int> graph[N];
vector<int> msg;
int ls = 0;
void dfs(int nd){
if(msg[nd] != -1) return;
msg[nd] = ls;
ls++, ls%=k;
for(int x: graph[nd]) dfs(x);
}
}
void Joi(int _n, int _m, int A[], int B[], ll X, int T){
n = _n, m = _m;
for(int i = 0; i < m; i++){
graph[A[i]].push_back(B[i]);
graph[B[i]].push_back(A[i]);
}
vector<int> bin;
for(int i = 0; i < k; i++){
bin.push_back(X%2);
X/=2;
}
msg.assign(n, -1);
dfs(0);
for(int i = 0; i < n; i++) MessageBoard(i, bin[msg[i]]);
}
#include "Ioi.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
namespace {
const int N = 10000;
const int k = 60;
int n, m;
vector<int> graph[N];
vector<int> tree0[N];
vector<int> tree[N];
vector<int> msg;
int ls = 0;
void dfs(int nd, int ss = -1){
if(msg[nd] != -1) return;
if(ss != -1){
tree0[ss].push_back(nd);
tree0[nd].push_back(ss);
}
msg[nd] = ls;
ls++, ls%=k;
for(int x: graph[nd]) dfs(x, nd);
}
}
ll Ioi(int _n, int _m, int A[], int B[], int p, int v, int T){
n = _n, m = _m;
for(int i = 0; i < m; i++){
graph[A[i]].push_back(B[i]);
graph[B[i]].push_back(A[i]);
}
msg.assign(n, -1);
dfs(0);
vector<bool> done(k, 0);
int left = k;
vector<bool> bl(n, 0);
done[msg[p]] = 1;
left--;
bl[p] = 1;
vector<pair<int, int>> nxt;
for(int x: tree0[p]) if(!bl[x]){
bl[x] = 1;
nxt.push_back({x, p});
}
while(left){
int nd = -1, ss = -1;
for(int i = 0; i < nxt.size(); i++) if(!done[msg[nxt[i].first]]){
tie(nd, ss) = nxt[i];
nxt.erase(nxt.begin()+i);
break;
}
if(nd == -1){
assert(!nxt.empty());
tie(nd, ss) = nxt.back();
nxt.pop_back();
}
if(!done[msg[nd]]) left--;
done[msg[nd]] = 1;
bl[nd] = 1;
tree[ss].push_back(nd);
for(int x: tree0[nd]) if(!bl[x]){
bl[x] = 1;
nxt.push_back({x, nd});
}
}
vector<int> bin(k);
bin[msg[p]] = v;
function<void(int, bool)> dfs2 = [&](int nd, bool r){
int sz = tree[nd].size();
random_shuffle(tree[nd].begin(), tree[nd].end());
for(int x: tree[nd]){
sz--;
bin[msg[x]] = Move(x);
if(sz != 0 || r)
dfs2(x, 1), Move(nd);
else
dfs2(x, 0);
}
};
dfs2(p, 2);
ll X = 0;
for(int i = 0; i < k; i++) if(bin[i]) X+=(1LL<<i);
return X;
}
Compilation message
Ioi.cpp: In function 'll Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:58:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | for(int i = 0; i < nxt.size(); i++) if(!done[msg[nxt[i].first]]){
| ~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1820 KB |
Output is correct |
2 |
Correct |
0 ms |
1812 KB |
Output is correct |
3 |
Correct |
1 ms |
1828 KB |
Output is correct |
4 |
Correct |
1 ms |
1820 KB |
Output is correct |
5 |
Correct |
1 ms |
1828 KB |
Output is correct |
6 |
Correct |
2 ms |
1808 KB |
Output is correct |
7 |
Correct |
2 ms |
1828 KB |
Output is correct |
8 |
Correct |
0 ms |
1828 KB |
Output is correct |
9 |
Correct |
2 ms |
1828 KB |
Output is correct |
10 |
Correct |
2 ms |
1812 KB |
Output is correct |
11 |
Correct |
3 ms |
2140 KB |
Output is correct |
12 |
Correct |
1 ms |
1812 KB |
Output is correct |
13 |
Correct |
1 ms |
1828 KB |
Output is correct |
14 |
Correct |
1 ms |
1820 KB |
Output is correct |
15 |
Correct |
0 ms |
1832 KB |
Output is correct |
16 |
Correct |
2 ms |
1820 KB |
Output is correct |
17 |
Correct |
2 ms |
1820 KB |
Output is correct |
18 |
Correct |
2 ms |
1832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
5144 KB |
Output is correct |
2 |
Correct |
17 ms |
5024 KB |
Output is correct |
3 |
Correct |
19 ms |
5156 KB |
Output is correct |
4 |
Correct |
10 ms |
3640 KB |
Output is correct |
5 |
Correct |
11 ms |
4160 KB |
Output is correct |
6 |
Correct |
11 ms |
4148 KB |
Output is correct |
7 |
Correct |
12 ms |
4152 KB |
Output is correct |
8 |
Correct |
10 ms |
4156 KB |
Output is correct |
9 |
Correct |
10 ms |
4164 KB |
Output is correct |
10 |
Correct |
10 ms |
4160 KB |
Output is correct |
11 |
Correct |
10 ms |
4124 KB |
Output is correct |
12 |
Correct |
8 ms |
3616 KB |
Output is correct |
13 |
Correct |
9 ms |
3624 KB |
Output is correct |
14 |
Correct |
10 ms |
3684 KB |
Output is correct |
15 |
Correct |
11 ms |
3652 KB |
Output is correct |
16 |
Correct |
10 ms |
3644 KB |
Output is correct |
17 |
Correct |
9 ms |
3776 KB |
Output is correct |
18 |
Correct |
10 ms |
3644 KB |
Output is correct |
19 |
Correct |
10 ms |
3640 KB |
Output is correct |
20 |
Correct |
7 ms |
4116 KB |
Output is correct |
21 |
Correct |
8 ms |
4152 KB |
Output is correct |
22 |
Correct |
10 ms |
3844 KB |
Output is correct |
23 |
Correct |
10 ms |
4164 KB |
Output is correct |
24 |
Correct |
11 ms |
3900 KB |
Output is correct |
25 |
Correct |
12 ms |
4148 KB |
Output is correct |
26 |
Correct |
10 ms |
4148 KB |
Output is correct |
27 |
Correct |
10 ms |
4156 KB |
Output is correct |
28 |
Correct |
11 ms |
4160 KB |
Output is correct |
29 |
Correct |
10 ms |
3620 KB |
Output is correct |
30 |
Correct |
9 ms |
3628 KB |
Output is correct |
31 |
Correct |
2 ms |
1824 KB |
Output is correct |
32 |
Correct |
2 ms |
1808 KB |
Output is correct |
33 |
Correct |
2 ms |
1820 KB |
Output is correct |
34 |
Correct |
2 ms |
1824 KB |
Output is correct |
35 |
Correct |
0 ms |
1808 KB |
Output is correct |
36 |
Correct |
2 ms |
1812 KB |
Output is correct |
37 |
Correct |
2 ms |
1824 KB |
Output is correct |
38 |
Correct |
2 ms |
2000 KB |
Output is correct |
39 |
Correct |
1 ms |
1868 KB |
Output is correct |
40 |
Correct |
1 ms |
1808 KB |
Output is correct |
41 |
Correct |
2 ms |
1812 KB |
Output is correct |
42 |
Correct |
1 ms |
1812 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1808 KB |
Output is correct |
2 |
Correct |
1 ms |
1812 KB |
Output is correct |
3 |
Correct |
1 ms |
1808 KB |
Output is correct |
4 |
Correct |
2 ms |
2108 KB |
Output is correct |
5 |
Correct |
2 ms |
2120 KB |
Output is correct |
6 |
Correct |
2 ms |
2112 KB |
Output is correct |
7 |
Correct |
2 ms |
2112 KB |
Output is correct |
8 |
Correct |
2 ms |
2364 KB |
Output is correct |
9 |
Correct |
9 ms |
4420 KB |
Output is correct |
10 |
Correct |
8 ms |
4408 KB |
Output is correct |
11 |
Correct |
8 ms |
4416 KB |
Output is correct |
12 |
Correct |
1 ms |
1812 KB |
Output is correct |
13 |
Correct |
1 ms |
1816 KB |
Output is correct |
14 |
Correct |
1 ms |
1824 KB |
Output is correct |
15 |
Correct |
0 ms |
1812 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
5160 KB |
Output is correct |
2 |
Partially correct |
16 ms |
5160 KB |
Partially correct |
3 |
Correct |
16 ms |
5100 KB |
Output is correct |
4 |
Correct |
9 ms |
3636 KB |
Output is correct |
5 |
Correct |
10 ms |
4156 KB |
Output is correct |
6 |
Correct |
10 ms |
4160 KB |
Output is correct |
7 |
Correct |
10 ms |
4160 KB |
Output is correct |
8 |
Correct |
12 ms |
3640 KB |
Output is correct |
9 |
Correct |
10 ms |
3904 KB |
Output is correct |
10 |
Correct |
10 ms |
3908 KB |
Output is correct |
11 |
Correct |
11 ms |
3984 KB |
Output is correct |
12 |
Correct |
9 ms |
3488 KB |
Output is correct |
13 |
Correct |
10 ms |
3624 KB |
Output is correct |
14 |
Correct |
10 ms |
3628 KB |
Output is correct |
15 |
Correct |
10 ms |
3648 KB |
Output is correct |
16 |
Correct |
11 ms |
4072 KB |
Output is correct |
17 |
Correct |
10 ms |
3644 KB |
Output is correct |
18 |
Correct |
10 ms |
3640 KB |
Output is correct |
19 |
Correct |
10 ms |
3648 KB |
Output is correct |
20 |
Correct |
8 ms |
4148 KB |
Output is correct |
21 |
Correct |
8 ms |
3964 KB |
Output is correct |
22 |
Correct |
10 ms |
4152 KB |
Output is correct |
23 |
Correct |
11 ms |
4044 KB |
Output is correct |
24 |
Correct |
12 ms |
4152 KB |
Output is correct |
25 |
Correct |
11 ms |
4160 KB |
Output is correct |
26 |
Correct |
11 ms |
4152 KB |
Output is correct |
27 |
Correct |
11 ms |
4148 KB |
Output is correct |
28 |
Correct |
10 ms |
3896 KB |
Output is correct |
29 |
Partially correct |
10 ms |
3628 KB |
Partially correct |
30 |
Correct |
11 ms |
3868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
5156 KB |
Output is correct |
2 |
Correct |
16 ms |
5152 KB |
Output is correct |
3 |
Correct |
20 ms |
5152 KB |
Output is correct |
4 |
Correct |
12 ms |
3636 KB |
Output is correct |
5 |
Correct |
10 ms |
4416 KB |
Output is correct |
6 |
Correct |
10 ms |
3680 KB |
Output is correct |
7 |
Correct |
10 ms |
3904 KB |
Output is correct |
8 |
Correct |
10 ms |
4152 KB |
Output is correct |
9 |
Incorrect |
10 ms |
4164 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |