#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]);
}
dfs(0);
for (int i = 0; i < n; i++) {
assert(used[i]);
}
//cerr << X << endl;
}
#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];
static int n;
static ll x;
static int cur;
void dfs2(int v) {
used[v] = 1;
vec.push_back(v);
d[v] = cur;
cur++;
if (cur >= 60) cur -= 60;
for (int to : gr[v]) {
if (used[to]) continue;
pr[to] = v;
dfs2(to);
vec.push_back(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;
int ind = -1;
int en;
for (int i = 0; i < vec.size(); i++) {
if (vec[i] == P) {
if (ind == -1)
ind = i;
en = i;
}
}
int cnt = 0;
set <int> S;
cur = P;
int i = ind;
while (S.size() < 60) {
S.insert(d[vec[i]]);
if (cur != vec[i]) used[vec[i]] = Move(vec[i]);
cur = vec[i];
if (used[vec[i]])
x |= (1LL << d[vec[i]]);
if (i == en) break;
i++;
}
// work
if (S.size() < 60) {
i = ind;
while (S.size() < 60) {
S.insert(d[vec[i]]);
if (cur != vec[i]) used[vec[i]] = Move(vec[i]);
cur = vec[i];
if (used[vec[i]])
x |= (1LL << d[vec[i]]);
if (i == 0) break;
i--;
}
}
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 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:46:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < vec.size(); i++) {
~~^~~~~~~~~~~~
Ioi.cpp:53:7: warning: unused variable 'cnt' [-Wunused-variable]
int cnt = 0;
^~~
Ioi.cpp:45:7: warning: 'en' may be used uninitialized in this function [-Wmaybe-uninitialized]
int en;
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1252 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
4612 KB |
Output is correct |
2 |
Correct |
32 ms |
4476 KB |
Output is correct |
3 |
Correct |
32 ms |
4608 KB |
Output is correct |
4 |
Correct |
19 ms |
3224 KB |
Output is correct |
5 |
Correct |
20 ms |
3488 KB |
Output is correct |
6 |
Correct |
19 ms |
3596 KB |
Output is correct |
7 |
Correct |
22 ms |
3616 KB |
Output is correct |
8 |
Correct |
20 ms |
3480 KB |
Output is correct |
9 |
Correct |
20 ms |
3528 KB |
Output is correct |
10 |
Correct |
19 ms |
3256 KB |
Output is correct |
11 |
Correct |
26 ms |
3100 KB |
Output is correct |
12 |
Correct |
18 ms |
3196 KB |
Output is correct |
13 |
Correct |
19 ms |
3080 KB |
Output is correct |
14 |
Correct |
19 ms |
3092 KB |
Output is correct |
15 |
Correct |
19 ms |
3276 KB |
Output is correct |
16 |
Correct |
20 ms |
3172 KB |
Output is correct |
17 |
Correct |
19 ms |
3284 KB |
Output is correct |
18 |
Correct |
20 ms |
3104 KB |
Output is correct |
19 |
Correct |
20 ms |
3292 KB |
Output is correct |
20 |
Correct |
17 ms |
3480 KB |
Output is correct |
21 |
Correct |
16 ms |
3636 KB |
Output is correct |
22 |
Correct |
22 ms |
3360 KB |
Output is correct |
23 |
Correct |
22 ms |
3540 KB |
Output is correct |
24 |
Correct |
20 ms |
3440 KB |
Output is correct |
25 |
Correct |
19 ms |
3488 KB |
Output is correct |
26 |
Correct |
19 ms |
3480 KB |
Output is correct |
27 |
Correct |
20 ms |
3480 KB |
Output is correct |
28 |
Correct |
19 ms |
3496 KB |
Output is correct |
29 |
Correct |
19 ms |
3364 KB |
Output is correct |
30 |
Correct |
19 ms |
3340 KB |
Output is correct |
31 |
Correct |
4 ms |
1404 KB |
Output is correct |
32 |
Correct |
5 ms |
1268 KB |
Output is correct |
33 |
Correct |
6 ms |
1404 KB |
Output is correct |
34 |
Correct |
5 ms |
1140 KB |
Output is correct |
35 |
Correct |
5 ms |
1272 KB |
Output is correct |
36 |
Correct |
5 ms |
1404 KB |
Output is correct |
37 |
Correct |
4 ms |
1496 KB |
Output is correct |
38 |
Incorrect |
5 ms |
1404 KB |
Wrong Answer [7] |
39 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1404 KB |
Output is correct |
2 |
Correct |
5 ms |
1268 KB |
Output is correct |
3 |
Correct |
5 ms |
1368 KB |
Output is correct |
4 |
Correct |
6 ms |
1696 KB |
Output is correct |
5 |
Correct |
6 ms |
1760 KB |
Output is correct |
6 |
Correct |
6 ms |
1704 KB |
Output is correct |
7 |
Correct |
6 ms |
1704 KB |
Output is correct |
8 |
Correct |
6 ms |
1696 KB |
Output is correct |
9 |
Correct |
16 ms |
3996 KB |
Output is correct |
10 |
Correct |
17 ms |
3880 KB |
Output is correct |
11 |
Correct |
17 ms |
4000 KB |
Output is correct |
12 |
Correct |
4 ms |
1432 KB |
Output is correct |
13 |
Correct |
4 ms |
1512 KB |
Output is correct |
14 |
Correct |
4 ms |
1268 KB |
Output is correct |
15 |
Correct |
4 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
4476 KB |
Output is correct |
2 |
Correct |
32 ms |
4656 KB |
Output is correct |
3 |
Partially correct |
32 ms |
4612 KB |
Partially correct |
4 |
Correct |
20 ms |
3260 KB |
Output is correct |
5 |
Correct |
20 ms |
3636 KB |
Output is correct |
6 |
Correct |
20 ms |
3736 KB |
Output is correct |
7 |
Correct |
19 ms |
3528 KB |
Output is correct |
8 |
Correct |
20 ms |
3396 KB |
Output is correct |
9 |
Correct |
20 ms |
3472 KB |
Output is correct |
10 |
Correct |
18 ms |
3100 KB |
Output is correct |
11 |
Correct |
18 ms |
3100 KB |
Output is correct |
12 |
Correct |
17 ms |
2944 KB |
Output is correct |
13 |
Correct |
19 ms |
2944 KB |
Output is correct |
14 |
Correct |
25 ms |
3216 KB |
Output is correct |
15 |
Partially correct |
20 ms |
3268 KB |
Partially correct |
16 |
Correct |
19 ms |
3260 KB |
Output is correct |
17 |
Correct |
19 ms |
3204 KB |
Output is correct |
18 |
Correct |
19 ms |
3256 KB |
Output is correct |
19 |
Correct |
19 ms |
3232 KB |
Output is correct |
20 |
Incorrect |
17 ms |
3616 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
4484 KB |
Output is correct |
2 |
Correct |
32 ms |
4484 KB |
Output is correct |
3 |
Incorrect |
33 ms |
4612 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |