#include <bits/stdc++.h>
#include "Joi.h"
#define ll long long
using namespace std;
const int maxn = (int)1e4 + 7;
static vector <int> gr[maxn];
static int used[maxn], d[maxn];
static int n, cur;
static ll x;
void dfs(int v) {
used[v] = 1;
MessageBoard(v, (x >> cur) & 1);
cur++;
if (cur >= 60) cur -= 60;
for (int to : gr[v]) {
if (used[to]) continue;
dfs(to);
}
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
n = N;
x = X;
for (int i = 0; i < M; i++) {
gr[A[i]].push_back(B[i]);
gr[B[i]].push_back(A[i]);
}
for (int i = 0; i < n; i++) {
used[i] = 0;
}
dfs(0);
}
#include <bits/stdc++.h>
#include "Ioi.h"
#define ll long long
using namespace std;
const int maxn = (int)1e4 + 7;
static int used[maxn], d[maxn], pr[maxn];
static vector <int> vec, gr[maxn], nwgr[maxn];
static int n;
static ll x;
static int cur = -1;
void dfs2(int v) {
used[v] = 1;
cur++;
if (cur >= 60) cur -= 60;
d[v] = cur;
for (int to : gr[v]) {
if (used[to]) continue;
pr[to] = v;
nwgr[v].push_back(to);
dfs2(to);
}
}
set <int> S;
int us[maxn];
void dfs3(int v) {
if (S.size() >= 60) return ;
us[v] = 1;
S.insert(d[v]);
if (used[v])
x |= (1LL << d[v]);
if (S.size() >= 60) return ;
int ind = -1;
for (int i = 0; i < nwgr[v].size(); i++) {
int to = nwgr[v][i];
if (us[to]) ind = i;
}
for (int i = ind + 1; i < nwgr[v].size(); i++) {
int to = nwgr[v][i];
used[to] = Move(to);
dfs3(to);
if (S.size() >= 60) return ;
Move(v);
}
for (int i = ind - 1; i >= 0; i--) {
int to = nwgr[v][i];
used[to] = Move(to);
dfs3(to);
if (S.size() >= 60) return ;
Move(v);
}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
n = N;
for (int i = 0; i < M; i++) {
gr[A[i]].push_back(B[i]);
gr[B[i]].push_back(A[i]);
}
for (int i = 0; i < n; i++) {
used[i] = 0;
}
dfs2(0);
for (int i = 0; i < n; i++) {
used[i] = 0;
}
used[P] = V;
while (S.size() < 60) {
dfs3(P);
if (S.size() >= 60) break;
P = pr[P];
used[P] = Move(P);
}
//cerr << x << endl;
return x;
}
Compilation message
Joi.cpp:11:24: warning: 'd' defined but not used [-Wunused-variable]
static int used[maxn], d[maxn];
^
Ioi.cpp: In function 'void dfs3(int)':
Ioi.cpp:40:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < nwgr[v].size(); i++) {
~~^~~~~~~~~~~~~~~~
Ioi.cpp:44:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = ind + 1; i < nwgr[v].size(); i++) {
~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1520 KB |
Output is correct |
2 |
Correct |
4 ms |
1520 KB |
Output is correct |
3 |
Correct |
6 ms |
1668 KB |
Output is correct |
4 |
Correct |
5 ms |
1656 KB |
Output is correct |
5 |
Correct |
4 ms |
1756 KB |
Output is correct |
6 |
Correct |
4 ms |
1632 KB |
Output is correct |
7 |
Correct |
4 ms |
1664 KB |
Output is correct |
8 |
Correct |
4 ms |
1656 KB |
Output is correct |
9 |
Correct |
4 ms |
1652 KB |
Output is correct |
10 |
Correct |
4 ms |
1520 KB |
Output is correct |
11 |
Correct |
8 ms |
1828 KB |
Output is correct |
12 |
Correct |
4 ms |
1392 KB |
Output is correct |
13 |
Correct |
4 ms |
1528 KB |
Output is correct |
14 |
Correct |
4 ms |
1528 KB |
Output is correct |
15 |
Correct |
4 ms |
1656 KB |
Output is correct |
16 |
Correct |
5 ms |
1656 KB |
Output is correct |
17 |
Correct |
4 ms |
1528 KB |
Output is correct |
18 |
Correct |
4 ms |
1668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
4564 KB |
Output is correct |
2 |
Correct |
33 ms |
4544 KB |
Output is correct |
3 |
Correct |
33 ms |
4672 KB |
Output is correct |
4 |
Correct |
20 ms |
3384 KB |
Output is correct |
5 |
Correct |
22 ms |
3812 KB |
Output is correct |
6 |
Correct |
20 ms |
3512 KB |
Output is correct |
7 |
Correct |
20 ms |
3684 KB |
Output is correct |
8 |
Correct |
20 ms |
3640 KB |
Output is correct |
9 |
Correct |
22 ms |
3664 KB |
Output is correct |
10 |
Correct |
18 ms |
3256 KB |
Output is correct |
11 |
Correct |
19 ms |
3488 KB |
Output is correct |
12 |
Correct |
19 ms |
3192 KB |
Output is correct |
13 |
Correct |
20 ms |
3248 KB |
Output is correct |
14 |
Correct |
20 ms |
3168 KB |
Output is correct |
15 |
Correct |
20 ms |
3408 KB |
Output is correct |
16 |
Correct |
20 ms |
3256 KB |
Output is correct |
17 |
Correct |
20 ms |
3384 KB |
Output is correct |
18 |
Correct |
20 ms |
3264 KB |
Output is correct |
19 |
Correct |
20 ms |
3392 KB |
Output is correct |
20 |
Correct |
16 ms |
3640 KB |
Output is correct |
21 |
Correct |
16 ms |
3640 KB |
Output is correct |
22 |
Correct |
20 ms |
3584 KB |
Output is correct |
23 |
Correct |
20 ms |
3540 KB |
Output is correct |
24 |
Correct |
22 ms |
3568 KB |
Output is correct |
25 |
Correct |
20 ms |
3576 KB |
Output is correct |
26 |
Correct |
22 ms |
3564 KB |
Output is correct |
27 |
Correct |
20 ms |
3648 KB |
Output is correct |
28 |
Correct |
20 ms |
3524 KB |
Output is correct |
29 |
Correct |
20 ms |
3468 KB |
Output is correct |
30 |
Correct |
20 ms |
3504 KB |
Output is correct |
31 |
Correct |
4 ms |
1760 KB |
Output is correct |
32 |
Correct |
4 ms |
1656 KB |
Output is correct |
33 |
Correct |
5 ms |
1772 KB |
Output is correct |
34 |
Correct |
4 ms |
1656 KB |
Output is correct |
35 |
Correct |
4 ms |
1520 KB |
Output is correct |
36 |
Correct |
4 ms |
1768 KB |
Output is correct |
37 |
Correct |
4 ms |
1660 KB |
Output is correct |
38 |
Correct |
4 ms |
1392 KB |
Output is correct |
39 |
Correct |
5 ms |
1656 KB |
Output is correct |
40 |
Correct |
4 ms |
1412 KB |
Output is correct |
41 |
Correct |
4 ms |
1520 KB |
Output is correct |
42 |
Correct |
4 ms |
1520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1628 KB |
Output is correct |
2 |
Correct |
4 ms |
1392 KB |
Output is correct |
3 |
Correct |
4 ms |
1656 KB |
Output is correct |
4 |
Correct |
6 ms |
2140 KB |
Output is correct |
5 |
Correct |
6 ms |
2040 KB |
Output is correct |
6 |
Correct |
6 ms |
1972 KB |
Output is correct |
7 |
Correct |
6 ms |
1936 KB |
Output is correct |
8 |
Correct |
6 ms |
1936 KB |
Output is correct |
9 |
Correct |
17 ms |
4384 KB |
Output is correct |
10 |
Correct |
17 ms |
4292 KB |
Output is correct |
11 |
Correct |
17 ms |
4152 KB |
Output is correct |
12 |
Correct |
4 ms |
1656 KB |
Output is correct |
13 |
Correct |
5 ms |
1656 KB |
Output is correct |
14 |
Correct |
4 ms |
1524 KB |
Output is correct |
15 |
Correct |
4 ms |
1660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
4656 KB |
Output is correct |
2 |
Partially correct |
33 ms |
4680 KB |
Partially correct |
3 |
Correct |
33 ms |
4748 KB |
Output is correct |
4 |
Correct |
20 ms |
3256 KB |
Output is correct |
5 |
Correct |
20 ms |
4024 KB |
Output is correct |
6 |
Correct |
20 ms |
3512 KB |
Output is correct |
7 |
Correct |
22 ms |
3688 KB |
Output is correct |
8 |
Correct |
20 ms |
3384 KB |
Output is correct |
9 |
Correct |
20 ms |
3652 KB |
Output is correct |
10 |
Correct |
18 ms |
3172 KB |
Output is correct |
11 |
Correct |
20 ms |
3384 KB |
Output is correct |
12 |
Correct |
20 ms |
3124 KB |
Output is correct |
13 |
Correct |
18 ms |
3352 KB |
Output is correct |
14 |
Correct |
20 ms |
3300 KB |
Output is correct |
15 |
Correct |
20 ms |
3256 KB |
Output is correct |
16 |
Correct |
20 ms |
3384 KB |
Output is correct |
17 |
Correct |
20 ms |
3256 KB |
Output is correct |
18 |
Correct |
20 ms |
3384 KB |
Output is correct |
19 |
Correct |
20 ms |
3256 KB |
Output is correct |
20 |
Correct |
16 ms |
3644 KB |
Output is correct |
21 |
Correct |
16 ms |
3924 KB |
Output is correct |
22 |
Correct |
20 ms |
3640 KB |
Output is correct |
23 |
Correct |
23 ms |
3520 KB |
Output is correct |
24 |
Correct |
20 ms |
3512 KB |
Output is correct |
25 |
Correct |
20 ms |
3640 KB |
Output is correct |
26 |
Correct |
20 ms |
3640 KB |
Output is correct |
27 |
Correct |
20 ms |
3512 KB |
Output is correct |
28 |
Correct |
20 ms |
3384 KB |
Output is correct |
29 |
Correct |
20 ms |
3240 KB |
Output is correct |
30 |
Correct |
20 ms |
3496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
4672 KB |
Output is correct |
2 |
Correct |
32 ms |
4524 KB |
Output is correct |
3 |
Correct |
33 ms |
4672 KB |
Output is correct |
4 |
Incorrect |
20 ms |
3132 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |