#include "Joi.h"
#include <iostream>
#include <vector>
using namespace std;
vector<int>G[10009]; int col[10009], v[20009], cnts;
void make_ransuu1(int B) {
for (int i = 0; i < B; i++) v[i] = i;
unsigned long long x = 777;
for (int i = 0; i < 1000000; i++) {
x ^= x << 13;
x ^= x >> 7;
x ^= x << 17;
int u1 = (x % B);
x ^= x << 13;
x ^= x >> 7;
x ^= x << 17;
int u2 = (x % B);
swap(v[u1], v[u2]);
}
}
void dfs(int pos) {
if (col[pos] >= 0) return;
col[pos] = cnts % 60; cnts++;
for (int i = 0; i < G[pos].size(); i++) dfs(G[pos][i]);
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
make_ransuu1(M);
for (int i = 0; i < M; i++) { G[A[v[i]]].push_back(B[v[i]]); G[B[v[i]]].push_back(A[v[i]]); }
for (int i = 0; i < N; i++) col[i] = -1;
dfs(0);
for (int i = 0; i < N; i++) MessageBoard(i, (X / (1LL << col[i])) % 2);
}
#include "Ioi.h"
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
vector<int>I[10009]; int dist[10009], par[10009], cols[10009], vv[20009], cntv;
int N, M; bool used[60];
void make_ransuu2(int B) {
for (int i = 0; i < B; i++) vv[i] = i;
unsigned long long x = 777;
for (int i = 0; i < 1000000; i++) {
x ^= x << 13;
x ^= x >> 7;
x ^= x << 17;
int u1 = (x % B);
x ^= x << 13;
x ^= x >> 7;
x ^= x << 17;
int u2 = (x % B);
swap(vv[u1], vv[u2]);
}
}
void dfs2(int pos) {
if (cols[pos] >= 0) return;
cols[pos] = cntv % 60; cntv++;
for (int i = 0; i < I[pos].size(); i++) dfs2(I[pos][i]);
}
vector<int> nearest(int sta, int rem) {
for (int i = 0; i < N; i++) dist[i] = (1 << 30);
queue<int>Q; Q.push(sta); dist[sta] = 0;
while (!Q.empty()) {
int pos = Q.front(); Q.pop();
for (int i = 0; i < I[pos].size(); i++) {
int to = I[pos][i];
if (dist[to] > dist[pos] + 1) {
dist[to] = dist[pos] + 1;
par[to] = pos;
Q.push(to);
}
}
}
int id = 0, minx = 10000;
for (int i = 0; i < N; i++) {
if (cols[i] == rem && dist[i] < minx) {
minx = dist[i]; id = i;
}
}
vector<int>U;
while (true) {
U.push_back(id); if (id == sta) break;
id = par[id];
}
reverse(U.begin(), U.end());
return U;
}
long long Ioi(int NN, int MM, int A[], int B[], int P, int V, int T) {
N = NN; M = MM; make_ransuu2(M);
for (int i = 0; i < M; i++) { I[A[vv[i]]].push_back(B[vv[i]]); I[B[vv[i]]].push_back(A[vv[i]]); }
for (int i = 0; i < N; i++) cols[i] = -1;
dfs2(0);
int cx = P; long long rem = 0;
for (int i = 0; i < 60; i++) {
vector<int>E; int id = -1;
for (int j = 0; j < 60; j++) {
if (used[j] == true) continue;
vector<int>F = nearest(cx, j);
if (E.size() == 0 || E.size() > F.size()) { E = F; id = j; }
}
int F = V;
for (int j = 1; j < E.size(); j++) {
F = Move(E[j]);
}
rem += 1LL * F * (1LL << id);
if (E.size() >= 1) cx = E[E.size() - 1];
used[id] = true;
}
return rem;
}
Compilation message
Joi.cpp: In function 'void dfs(int)':
Joi.cpp:28:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < G[pos].size(); i++) dfs(G[pos][i]);
~~^~~~~~~~~~~~~~~
Ioi.cpp: In function 'void dfs2(int)':
Ioi.cpp:31:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < I[pos].size(); i++) dfs2(I[pos][i]);
~~^~~~~~~~~~~~~~~
Ioi.cpp: In function 'std::vector<int> nearest(int, int)':
Ioi.cpp:40:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < I[pos].size(); i++) {
~~^~~~~~~~~~~~~~~
Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:81:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 1; j < E.size(); j++) {
~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
1272 KB |
Output is correct |
2 |
Correct |
53 ms |
1152 KB |
Output is correct |
3 |
Correct |
52 ms |
1404 KB |
Output is correct |
4 |
Correct |
55 ms |
1288 KB |
Output is correct |
5 |
Correct |
45 ms |
1152 KB |
Output is correct |
6 |
Correct |
59 ms |
1152 KB |
Output is correct |
7 |
Correct |
52 ms |
1276 KB |
Output is correct |
8 |
Correct |
49 ms |
1284 KB |
Output is correct |
9 |
Correct |
51 ms |
1388 KB |
Output is correct |
10 |
Correct |
45 ms |
1152 KB |
Output is correct |
11 |
Correct |
64 ms |
1584 KB |
Output is correct |
12 |
Correct |
48 ms |
1144 KB |
Output is correct |
13 |
Correct |
50 ms |
1524 KB |
Output is correct |
14 |
Correct |
52 ms |
1320 KB |
Output is correct |
15 |
Correct |
61 ms |
1396 KB |
Output is correct |
16 |
Correct |
55 ms |
1364 KB |
Output is correct |
17 |
Correct |
48 ms |
1424 KB |
Output is correct |
18 |
Correct |
47 ms |
1404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
964 ms |
4248 KB |
Output is correct |
2 |
Correct |
1055 ms |
4044 KB |
Output is correct |
3 |
Correct |
986 ms |
4188 KB |
Output is correct |
4 |
Correct |
748 ms |
2780 KB |
Output is correct |
5 |
Correct |
978 ms |
3248 KB |
Output is correct |
6 |
Correct |
949 ms |
3124 KB |
Output is correct |
7 |
Correct |
836 ms |
3120 KB |
Output is correct |
8 |
Correct |
788 ms |
3120 KB |
Output is correct |
9 |
Correct |
874 ms |
3080 KB |
Output is correct |
10 |
Correct |
449 ms |
2964 KB |
Output is correct |
11 |
Correct |
501 ms |
2864 KB |
Output is correct |
12 |
Correct |
504 ms |
2856 KB |
Output is correct |
13 |
Correct |
470 ms |
2704 KB |
Output is correct |
14 |
Correct |
461 ms |
2836 KB |
Output is correct |
15 |
Correct |
610 ms |
2768 KB |
Output is correct |
16 |
Correct |
657 ms |
2872 KB |
Output is correct |
17 |
Correct |
735 ms |
3000 KB |
Output is correct |
18 |
Correct |
633 ms |
2904 KB |
Output is correct |
19 |
Correct |
770 ms |
2976 KB |
Output is correct |
20 |
Correct |
420 ms |
3120 KB |
Output is correct |
21 |
Correct |
489 ms |
3128 KB |
Output is correct |
22 |
Correct |
635 ms |
3052 KB |
Output is correct |
23 |
Correct |
601 ms |
2992 KB |
Output is correct |
24 |
Correct |
622 ms |
2980 KB |
Output is correct |
25 |
Correct |
610 ms |
3000 KB |
Output is correct |
26 |
Correct |
638 ms |
3012 KB |
Output is correct |
27 |
Correct |
568 ms |
3168 KB |
Output is correct |
28 |
Correct |
644 ms |
3104 KB |
Output is correct |
29 |
Correct |
508 ms |
2956 KB |
Output is correct |
30 |
Correct |
627 ms |
2912 KB |
Output is correct |
31 |
Correct |
47 ms |
1360 KB |
Output is correct |
32 |
Correct |
56 ms |
1372 KB |
Output is correct |
33 |
Correct |
51 ms |
1388 KB |
Output is correct |
34 |
Correct |
58 ms |
1264 KB |
Output is correct |
35 |
Correct |
49 ms |
1388 KB |
Output is correct |
36 |
Correct |
56 ms |
1124 KB |
Output is correct |
37 |
Correct |
50 ms |
1380 KB |
Output is correct |
38 |
Correct |
52 ms |
1248 KB |
Output is correct |
39 |
Correct |
57 ms |
1100 KB |
Output is correct |
40 |
Correct |
53 ms |
1240 KB |
Output is correct |
41 |
Correct |
45 ms |
1248 KB |
Output is correct |
42 |
Correct |
47 ms |
1244 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
1304 KB |
Output is correct |
2 |
Correct |
48 ms |
1244 KB |
Output is correct |
3 |
Correct |
54 ms |
1288 KB |
Output is correct |
4 |
Correct |
103 ms |
1560 KB |
Output is correct |
5 |
Correct |
100 ms |
1676 KB |
Output is correct |
6 |
Correct |
103 ms |
1808 KB |
Output is correct |
7 |
Correct |
106 ms |
1684 KB |
Output is correct |
8 |
Correct |
110 ms |
1728 KB |
Output is correct |
9 |
Correct |
515 ms |
3432 KB |
Output is correct |
10 |
Correct |
584 ms |
3492 KB |
Output is correct |
11 |
Correct |
585 ms |
3480 KB |
Output is correct |
12 |
Correct |
51 ms |
1180 KB |
Output is correct |
13 |
Correct |
46 ms |
1152 KB |
Output is correct |
14 |
Correct |
54 ms |
1288 KB |
Output is correct |
15 |
Correct |
51 ms |
1288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1063 ms |
4208 KB |
Output is correct |
2 |
Correct |
1090 ms |
4132 KB |
Output is correct |
3 |
Correct |
970 ms |
4144 KB |
Output is correct |
4 |
Correct |
821 ms |
2992 KB |
Output is correct |
5 |
Correct |
972 ms |
3384 KB |
Output is correct |
6 |
Correct |
819 ms |
3104 KB |
Output is correct |
7 |
Correct |
851 ms |
3232 KB |
Output is correct |
8 |
Correct |
853 ms |
3016 KB |
Output is correct |
9 |
Correct |
731 ms |
2960 KB |
Output is correct |
10 |
Correct |
465 ms |
3100 KB |
Output is correct |
11 |
Correct |
444 ms |
3028 KB |
Output is correct |
12 |
Correct |
570 ms |
2800 KB |
Output is correct |
13 |
Correct |
600 ms |
2700 KB |
Output is correct |
14 |
Correct |
505 ms |
2796 KB |
Output is correct |
15 |
Correct |
748 ms |
2772 KB |
Output is correct |
16 |
Correct |
766 ms |
2852 KB |
Output is correct |
17 |
Correct |
692 ms |
2988 KB |
Output is correct |
18 |
Correct |
751 ms |
2992 KB |
Output is correct |
19 |
Correct |
641 ms |
2864 KB |
Output is correct |
20 |
Correct |
480 ms |
3172 KB |
Output is correct |
21 |
Correct |
419 ms |
3188 KB |
Output is correct |
22 |
Correct |
617 ms |
3020 KB |
Output is correct |
23 |
Correct |
573 ms |
3072 KB |
Output is correct |
24 |
Correct |
515 ms |
3076 KB |
Output is correct |
25 |
Partially correct |
518 ms |
3124 KB |
Partially correct |
26 |
Correct |
547 ms |
3000 KB |
Output is correct |
27 |
Correct |
565 ms |
3260 KB |
Output is correct |
28 |
Correct |
559 ms |
3028 KB |
Output is correct |
29 |
Correct |
526 ms |
2984 KB |
Output is correct |
30 |
Correct |
513 ms |
3000 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1088 ms |
4044 KB |
Output is correct |
2 |
Correct |
1058 ms |
4240 KB |
Output is correct |
3 |
Correct |
1052 ms |
4156 KB |
Output is correct |
4 |
Correct |
769 ms |
3000 KB |
Output is correct |
5 |
Correct |
975 ms |
3592 KB |
Output is correct |
6 |
Correct |
838 ms |
3204 KB |
Output is correct |
7 |
Correct |
719 ms |
2964 KB |
Output is correct |
8 |
Correct |
725 ms |
3020 KB |
Output is correct |
9 |
Correct |
832 ms |
2992 KB |
Output is correct |
10 |
Correct |
380 ms |
3008 KB |
Output is correct |
11 |
Correct |
408 ms |
3084 KB |
Output is correct |
12 |
Correct |
443 ms |
2720 KB |
Output is correct |
13 |
Correct |
535 ms |
2708 KB |
Output is correct |
14 |
Correct |
523 ms |
2964 KB |
Output is correct |
15 |
Correct |
681 ms |
2944 KB |
Output is correct |
16 |
Correct |
620 ms |
2764 KB |
Output is correct |
17 |
Correct |
722 ms |
2960 KB |
Output is correct |
18 |
Correct |
723 ms |
2936 KB |
Output is correct |
19 |
Correct |
746 ms |
2940 KB |
Output is correct |
20 |
Correct |
502 ms |
3236 KB |
Output is correct |
21 |
Correct |
424 ms |
3168 KB |
Output is correct |
22 |
Correct |
624 ms |
3204 KB |
Output is correct |
23 |
Correct |
645 ms |
3020 KB |
Output is correct |
24 |
Correct |
604 ms |
3036 KB |
Output is correct |
25 |
Correct |
566 ms |
3116 KB |
Output is correct |
26 |
Correct |
558 ms |
3048 KB |
Output is correct |
27 |
Correct |
576 ms |
3196 KB |
Output is correct |
28 |
Correct |
554 ms |
3240 KB |
Output is correct |
29 |
Correct |
586 ms |
3048 KB |
Output is correct |
30 |
Correct |
612 ms |
2980 KB |
Output is correct |
31 |
Correct |
52 ms |
1400 KB |
Output is correct |
32 |
Correct |
48 ms |
1240 KB |
Output is correct |
33 |
Correct |
60 ms |
1420 KB |
Output is correct |
34 |
Correct |
56 ms |
1480 KB |
Output is correct |
35 |
Correct |
57 ms |
1508 KB |
Output is correct |
36 |
Correct |
54 ms |
1292 KB |
Output is correct |
37 |
Correct |
55 ms |
1416 KB |
Output is correct |
38 |
Correct |
47 ms |
1368 KB |
Output is correct |
39 |
Correct |
52 ms |
1292 KB |
Output is correct |
40 |
Incorrect |
48 ms |
1376 KB |
Output isn't correct |
41 |
Halted |
0 ms |
0 KB |
- |