#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]);
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:39:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < nwgr[v].size(); i++) {
~~^~~~~~~~~~~~~~~~
Ioi.cpp:43:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = ind + 1; i < nwgr[v].size(); i++) {
~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1392 KB |
Output is correct |
2 |
Correct |
4 ms |
1392 KB |
Output is correct |
3 |
Correct |
11 ms |
1664 KB |
Output is correct |
4 |
Correct |
4 ms |
1392 KB |
Output is correct |
5 |
Correct |
4 ms |
1520 KB |
Output is correct |
6 |
Correct |
4 ms |
1656 KB |
Output is correct |
7 |
Correct |
4 ms |
1656 KB |
Output is correct |
8 |
Correct |
4 ms |
1528 KB |
Output is correct |
9 |
Correct |
5 ms |
1772 KB |
Output is correct |
10 |
Correct |
4 ms |
1524 KB |
Output is correct |
11 |
Correct |
8 ms |
1956 KB |
Output is correct |
12 |
Correct |
4 ms |
1524 KB |
Output is correct |
13 |
Correct |
4 ms |
1656 KB |
Output is correct |
14 |
Correct |
4 ms |
1648 KB |
Output is correct |
15 |
Correct |
4 ms |
1752 KB |
Output is correct |
16 |
Correct |
4 ms |
1528 KB |
Output is correct |
17 |
Correct |
4 ms |
1656 KB |
Output is correct |
18 |
Correct |
4 ms |
1744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
4680 KB |
Output is correct |
2 |
Correct |
32 ms |
4672 KB |
Output is correct |
3 |
Correct |
33 ms |
4552 KB |
Output is correct |
4 |
Correct |
20 ms |
3256 KB |
Output is correct |
5 |
Correct |
23 ms |
3684 KB |
Output is correct |
6 |
Correct |
20 ms |
3684 KB |
Output is correct |
7 |
Correct |
20 ms |
3656 KB |
Output is correct |
8 |
Correct |
20 ms |
3640 KB |
Output is correct |
9 |
Correct |
20 ms |
3668 KB |
Output is correct |
10 |
Correct |
18 ms |
3476 KB |
Output is correct |
11 |
Correct |
18 ms |
3264 KB |
Output is correct |
12 |
Correct |
18 ms |
3112 KB |
Output is correct |
13 |
Correct |
22 ms |
3212 KB |
Output is correct |
14 |
Correct |
20 ms |
3120 KB |
Output is correct |
15 |
Correct |
20 ms |
3264 KB |
Output is correct |
16 |
Correct |
20 ms |
3420 KB |
Output is correct |
17 |
Correct |
20 ms |
3516 KB |
Output is correct |
18 |
Correct |
20 ms |
3288 KB |
Output is correct |
19 |
Correct |
20 ms |
3256 KB |
Output is correct |
20 |
Correct |
16 ms |
3640 KB |
Output is correct |
21 |
Correct |
17 ms |
3640 KB |
Output is correct |
22 |
Correct |
20 ms |
3520 KB |
Output is correct |
23 |
Correct |
20 ms |
3520 KB |
Output is correct |
24 |
Correct |
20 ms |
3640 KB |
Output is correct |
25 |
Correct |
20 ms |
3512 KB |
Output is correct |
26 |
Correct |
20 ms |
3648 KB |
Output is correct |
27 |
Correct |
20 ms |
3684 KB |
Output is correct |
28 |
Correct |
20 ms |
3512 KB |
Output is correct |
29 |
Correct |
20 ms |
3240 KB |
Output is correct |
30 |
Correct |
20 ms |
3512 KB |
Output is correct |
31 |
Correct |
4 ms |
1392 KB |
Output is correct |
32 |
Correct |
4 ms |
1392 KB |
Output is correct |
33 |
Correct |
4 ms |
1656 KB |
Output is correct |
34 |
Correct |
4 ms |
1520 KB |
Output is correct |
35 |
Correct |
4 ms |
1532 KB |
Output is correct |
36 |
Correct |
4 ms |
1392 KB |
Output is correct |
37 |
Correct |
5 ms |
1392 KB |
Output is correct |
38 |
Correct |
4 ms |
1528 KB |
Output is correct |
39 |
Correct |
4 ms |
1520 KB |
Output is correct |
40 |
Correct |
4 ms |
1396 KB |
Output is correct |
41 |
Correct |
4 ms |
1520 KB |
Output is correct |
42 |
Correct |
4 ms |
1636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1524 KB |
Output is correct |
2 |
Correct |
4 ms |
1628 KB |
Output is correct |
3 |
Correct |
4 ms |
1396 KB |
Output is correct |
4 |
Correct |
6 ms |
1936 KB |
Output is correct |
5 |
Correct |
6 ms |
1936 KB |
Output is correct |
6 |
Correct |
6 ms |
2044 KB |
Output is correct |
7 |
Correct |
6 ms |
1936 KB |
Output is correct |
8 |
Correct |
6 ms |
2012 KB |
Output is correct |
9 |
Correct |
18 ms |
4152 KB |
Output is correct |
10 |
Correct |
17 ms |
4172 KB |
Output is correct |
11 |
Correct |
17 ms |
4256 KB |
Output is correct |
12 |
Correct |
4 ms |
1656 KB |
Output is correct |
13 |
Correct |
4 ms |
1392 KB |
Output is correct |
14 |
Correct |
4 ms |
1452 KB |
Output is correct |
15 |
Correct |
4 ms |
1396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
4524 KB |
Output is correct |
2 |
Partially correct |
33 ms |
4552 KB |
Partially correct |
3 |
Correct |
33 ms |
4740 KB |
Output is correct |
4 |
Correct |
20 ms |
3316 KB |
Output is correct |
5 |
Correct |
20 ms |
3896 KB |
Output is correct |
6 |
Correct |
20 ms |
3512 KB |
Output is correct |
7 |
Correct |
22 ms |
3644 KB |
Output is correct |
8 |
Correct |
20 ms |
3512 KB |
Output is correct |
9 |
Correct |
22 ms |
3580 KB |
Output is correct |
10 |
Correct |
18 ms |
3240 KB |
Output is correct |
11 |
Correct |
18 ms |
3392 KB |
Output is correct |
12 |
Correct |
18 ms |
3116 KB |
Output is correct |
13 |
Correct |
18 ms |
3116 KB |
Output is correct |
14 |
Correct |
20 ms |
3248 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 |
3264 KB |
Output is correct |
18 |
Correct |
20 ms |
3156 KB |
Output is correct |
19 |
Correct |
20 ms |
3256 KB |
Output is correct |
20 |
Correct |
16 ms |
3772 KB |
Output is correct |
21 |
Correct |
16 ms |
3868 KB |
Output is correct |
22 |
Correct |
20 ms |
3844 KB |
Output is correct |
23 |
Correct |
20 ms |
3744 KB |
Output is correct |
24 |
Correct |
20 ms |
3864 KB |
Output is correct |
25 |
Correct |
20 ms |
3612 KB |
Output is correct |
26 |
Correct |
20 ms |
3844 KB |
Output is correct |
27 |
Correct |
20 ms |
3872 KB |
Output is correct |
28 |
Correct |
23 ms |
3736 KB |
Output is correct |
29 |
Correct |
20 ms |
3596 KB |
Output is correct |
30 |
Correct |
20 ms |
3828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
4736 KB |
Output is correct |
2 |
Correct |
34 ms |
4704 KB |
Output is correct |
3 |
Correct |
34 ms |
4680 KB |
Output is correct |
4 |
Incorrect |
22 ms |
3480 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |