#include "Joi.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int _N = 1e4+1, _B = 60;
vector<int> g[_N];
bool vis[_N];
int dep[_N], par[_N];
vector<int> roots;
ll X;
void dfs(int x) {
vis[x] = 1;
if(dep[x]%_B==0) {
roots.push_back(x);
}
for(int i: g[x]) {
if(!vis[i]) {
par[i] = x;
dep[i] = dep[x]+1;
dfs(i);
}
}
}
void set_board(int x, int &bit) {
vis[x] = 1;
if((X&(1LL<<bit))>0) {
MessageBoard(x, 1);
}
else {
MessageBoard(x, 0);
}
if(bit>=_B-1) return;
for(int i: g[x]) {
if(!vis[i] && par[i] == x) {
bit++;
if(dep[i]%_B!=0 && bit<_B) set_board(i, bit);
}
}
}
void Joi(int N, int M, int A[], int B[], ll _X, int T) {
// MessageBoard();
X = _X;
for(int i=0; i<M; ++i) {
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
for(int i=0; i<N; ++i) {
sort(g[i].begin(), g[i].end());
}
dfs(0);
for(int i=0; i<N; ++i) vis[i] = 0;
for(int i: roots) {
int bit = 0;
set_board(i, bit);
}
for(int i=0; i<N; ++i) {
if(!vis[i]) {
MessageBoard(i, 1);
}
}
}
#include "Ioi.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int __N = 1e4+1;
const int bits = 60;
void _dfs(int x, vector<int>& vis, vector<vector<int>>& g, vector<int>& par, vector<int>& dep) {
vis[x] = 1;
for(int i: g[x]) {
if(!vis[i]) {
par[i] = x;
dep[i] = dep[x]+1;
_dfs(i, vis, g, par, dep);
}
}
}
void get_X(int x, int v, int& bit, ll& X, vector<int>& vis, vector<vector<int>>& g, vector<int>& par) {
vis[x] = 1;
X += (ll)v * (1LL<<bit);
if(bit==bits-1) return;
for(int i: g[x]) {
if(!vis[i] && par[i]==x) {
bit++;
if(bit < bits) get_X(i, Move(i), bit, X, vis, g, par);
}
}
if(par[x] != x && bit < bits-1) {
Move(par[x]);
}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
vector<vector<int>> g(N);
vector<int> vis(N), par(N), dep(N);
for(int i=0; i<M; ++i) {
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
for(int i=0; i<N; ++i) {
sort(g[i].begin(), g[i].end());
}
_dfs(0, vis, g, par, dep);
while(dep[P]%bits != 0) {
P = par[P];
V = Move(P);
}
for(int i=0; i<N; ++i) {
vis[i] = 0;
}
int bit = 0;
ll X = 0;
get_X(P, V, bit, X, vis, g, par);
return X;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1036 KB |
Output is correct |
2 |
Correct |
3 ms |
1536 KB |
Output is correct |
3 |
Correct |
2 ms |
1344 KB |
Output is correct |
4 |
Correct |
2 ms |
1412 KB |
Output is correct |
5 |
Correct |
2 ms |
1288 KB |
Output is correct |
6 |
Correct |
2 ms |
1280 KB |
Output is correct |
7 |
Correct |
2 ms |
1280 KB |
Output is correct |
8 |
Correct |
2 ms |
1280 KB |
Output is correct |
9 |
Correct |
2 ms |
1280 KB |
Output is correct |
10 |
Correct |
2 ms |
1280 KB |
Output is correct |
11 |
Correct |
6 ms |
1536 KB |
Output is correct |
12 |
Correct |
2 ms |
1280 KB |
Output is correct |
13 |
Correct |
2 ms |
1280 KB |
Output is correct |
14 |
Correct |
2 ms |
1280 KB |
Output is correct |
15 |
Correct |
2 ms |
1280 KB |
Output is correct |
16 |
Correct |
2 ms |
1280 KB |
Output is correct |
17 |
Correct |
2 ms |
1280 KB |
Output is correct |
18 |
Correct |
2 ms |
1280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
4524 KB |
Output is correct |
2 |
Correct |
32 ms |
4772 KB |
Output is correct |
3 |
Correct |
32 ms |
5160 KB |
Output is correct |
4 |
Correct |
19 ms |
3132 KB |
Output is correct |
5 |
Correct |
19 ms |
3644 KB |
Output is correct |
6 |
Correct |
19 ms |
3516 KB |
Output is correct |
7 |
Correct |
20 ms |
3628 KB |
Output is correct |
8 |
Correct |
19 ms |
3720 KB |
Output is correct |
9 |
Correct |
20 ms |
3644 KB |
Output is correct |
10 |
Correct |
18 ms |
3360 KB |
Output is correct |
11 |
Correct |
19 ms |
3136 KB |
Output is correct |
12 |
Correct |
17 ms |
2980 KB |
Output is correct |
13 |
Correct |
17 ms |
2852 KB |
Output is correct |
14 |
Correct |
17 ms |
3028 KB |
Output is correct |
15 |
Correct |
19 ms |
3004 KB |
Output is correct |
16 |
Correct |
19 ms |
3004 KB |
Output is correct |
17 |
Correct |
19 ms |
3272 KB |
Output is correct |
18 |
Correct |
19 ms |
3640 KB |
Output is correct |
19 |
Correct |
19 ms |
3508 KB |
Output is correct |
20 |
Correct |
17 ms |
3644 KB |
Output is correct |
21 |
Correct |
15 ms |
3688 KB |
Output is correct |
22 |
Correct |
19 ms |
3396 KB |
Output is correct |
23 |
Correct |
19 ms |
3724 KB |
Output is correct |
24 |
Correct |
18 ms |
3516 KB |
Output is correct |
25 |
Correct |
20 ms |
3644 KB |
Output is correct |
26 |
Correct |
19 ms |
3720 KB |
Output is correct |
27 |
Correct |
19 ms |
3848 KB |
Output is correct |
28 |
Correct |
19 ms |
3712 KB |
Output is correct |
29 |
Correct |
17 ms |
3236 KB |
Output is correct |
30 |
Correct |
18 ms |
3440 KB |
Output is correct |
31 |
Correct |
2 ms |
1024 KB |
Output is correct |
32 |
Correct |
3 ms |
1280 KB |
Output is correct |
33 |
Correct |
2 ms |
1280 KB |
Output is correct |
34 |
Correct |
2 ms |
1280 KB |
Output is correct |
35 |
Correct |
2 ms |
1280 KB |
Output is correct |
36 |
Correct |
2 ms |
1280 KB |
Output is correct |
37 |
Correct |
2 ms |
1032 KB |
Output is correct |
38 |
Correct |
3 ms |
1280 KB |
Output is correct |
39 |
Correct |
2 ms |
1292 KB |
Output is correct |
40 |
Correct |
2 ms |
1280 KB |
Output is correct |
41 |
Correct |
2 ms |
1280 KB |
Output is correct |
42 |
Correct |
2 ms |
1280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1032 KB |
Output is correct |
2 |
Correct |
3 ms |
1292 KB |
Output is correct |
3 |
Incorrect |
2 ms |
1284 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
31 ms |
4520 KB |
Partially correct |
2 |
Correct |
32 ms |
4784 KB |
Output is correct |
3 |
Correct |
34 ms |
4904 KB |
Output is correct |
4 |
Correct |
18 ms |
3248 KB |
Output is correct |
5 |
Correct |
19 ms |
4076 KB |
Output is correct |
6 |
Partially correct |
19 ms |
3708 KB |
Partially correct |
7 |
Correct |
19 ms |
3728 KB |
Output is correct |
8 |
Correct |
19 ms |
3428 KB |
Output is correct |
9 |
Correct |
19 ms |
3760 KB |
Output is correct |
10 |
Correct |
17 ms |
3296 KB |
Output is correct |
11 |
Correct |
18 ms |
3136 KB |
Output is correct |
12 |
Correct |
16 ms |
3056 KB |
Output is correct |
13 |
Partially correct |
17 ms |
3112 KB |
Partially correct |
14 |
Partially correct |
17 ms |
3036 KB |
Partially correct |
15 |
Correct |
18 ms |
3136 KB |
Output is correct |
16 |
Correct |
19 ms |
3448 KB |
Output is correct |
17 |
Correct |
20 ms |
3380 KB |
Output is correct |
18 |
Partially correct |
19 ms |
3516 KB |
Partially correct |
19 |
Partially correct |
19 ms |
3632 KB |
Partially correct |
20 |
Partially correct |
16 ms |
3772 KB |
Partially correct |
21 |
Correct |
16 ms |
3644 KB |
Output is correct |
22 |
Correct |
22 ms |
3576 KB |
Output is correct |
23 |
Correct |
19 ms |
3624 KB |
Output is correct |
24 |
Partially correct |
19 ms |
3628 KB |
Partially correct |
25 |
Partially correct |
18 ms |
3644 KB |
Partially correct |
26 |
Correct |
19 ms |
3516 KB |
Output is correct |
27 |
Correct |
19 ms |
3688 KB |
Output is correct |
28 |
Correct |
19 ms |
3392 KB |
Output is correct |
29 |
Correct |
17 ms |
3236 KB |
Output is correct |
30 |
Partially correct |
18 ms |
3624 KB |
Partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
4324 KB |
Output is correct |
2 |
Incorrect |
33 ms |
4644 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |