#include "Joi.h"
#include <iostream>
#include <vector>
using namespace std;
vector<int>G[10009]; int col[10009], cnts;
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) {
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++) 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], cntv;
int N, M;
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;
for (int i = 0; i < M; i++) { I[A[i]].push_back(B[i]); I[B[i]].push_back(A[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 = nearest(cx, (P + i) % 60);
int F = V;
for (int j = 1; j < E.size(); j++) {
F = Move(E[j]);
}
rem += 1LL * F * (1LL << ((P + i) % 60));
if (E.size() >= 1) cx = E[E.size() - 1];
}
return rem;
}
Compilation message
Joi.cpp: In function 'void dfs(int)':
Joi.cpp:11: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:13: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:22: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:58:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 1; j < E.size(); j++) {
~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1160 KB |
Output is correct |
2 |
Correct |
6 ms |
1152 KB |
Output is correct |
3 |
Correct |
5 ms |
1288 KB |
Output is correct |
4 |
Correct |
6 ms |
1152 KB |
Output is correct |
5 |
Correct |
5 ms |
1288 KB |
Output is correct |
6 |
Correct |
6 ms |
1288 KB |
Output is correct |
7 |
Correct |
6 ms |
1156 KB |
Output is correct |
8 |
Correct |
6 ms |
1400 KB |
Output is correct |
9 |
Correct |
8 ms |
1284 KB |
Output is correct |
10 |
Correct |
6 ms |
1564 KB |
Output is correct |
11 |
Correct |
8 ms |
1584 KB |
Output is correct |
12 |
Correct |
6 ms |
1288 KB |
Output is correct |
13 |
Correct |
6 ms |
1284 KB |
Output is correct |
14 |
Correct |
4 ms |
1284 KB |
Output is correct |
15 |
Correct |
4 ms |
1156 KB |
Output is correct |
16 |
Correct |
6 ms |
1284 KB |
Output is correct |
17 |
Correct |
5 ms |
1284 KB |
Output is correct |
18 |
Correct |
6 ms |
1156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
4316 KB |
Output is correct |
2 |
Correct |
62 ms |
4360 KB |
Output is correct |
3 |
Correct |
78 ms |
4340 KB |
Output is correct |
4 |
Correct |
41 ms |
2936 KB |
Output is correct |
5 |
Correct |
48 ms |
3272 KB |
Output is correct |
6 |
Correct |
48 ms |
3180 KB |
Output is correct |
7 |
Correct |
51 ms |
3176 KB |
Output is correct |
8 |
Correct |
45 ms |
3292 KB |
Output is correct |
9 |
Correct |
44 ms |
2936 KB |
Output is correct |
10 |
Correct |
31 ms |
2940 KB |
Output is correct |
11 |
Correct |
35 ms |
3196 KB |
Output is correct |
12 |
Correct |
40 ms |
2692 KB |
Output is correct |
13 |
Correct |
30 ms |
2720 KB |
Output is correct |
14 |
Correct |
31 ms |
2668 KB |
Output is correct |
15 |
Correct |
44 ms |
2932 KB |
Output is correct |
16 |
Correct |
41 ms |
3064 KB |
Output is correct |
17 |
Correct |
38 ms |
3048 KB |
Output is correct |
18 |
Correct |
41 ms |
3072 KB |
Output is correct |
19 |
Correct |
40 ms |
2936 KB |
Output is correct |
20 |
Correct |
27 ms |
3220 KB |
Output is correct |
21 |
Correct |
23 ms |
3072 KB |
Output is correct |
22 |
Correct |
40 ms |
3064 KB |
Output is correct |
23 |
Correct |
33 ms |
3204 KB |
Output is correct |
24 |
Correct |
36 ms |
3072 KB |
Output is correct |
25 |
Correct |
31 ms |
3200 KB |
Output is correct |
26 |
Correct |
31 ms |
3068 KB |
Output is correct |
27 |
Correct |
32 ms |
3064 KB |
Output is correct |
28 |
Correct |
48 ms |
3192 KB |
Output is correct |
29 |
Correct |
32 ms |
3040 KB |
Output is correct |
30 |
Correct |
29 ms |
3052 KB |
Output is correct |
31 |
Correct |
4 ms |
1152 KB |
Output is correct |
32 |
Correct |
6 ms |
1288 KB |
Output is correct |
33 |
Correct |
4 ms |
1292 KB |
Output is correct |
34 |
Correct |
5 ms |
1284 KB |
Output is correct |
35 |
Correct |
4 ms |
1260 KB |
Output is correct |
36 |
Correct |
4 ms |
1156 KB |
Output is correct |
37 |
Correct |
4 ms |
1152 KB |
Output is correct |
38 |
Correct |
6 ms |
1416 KB |
Output is correct |
39 |
Correct |
4 ms |
1160 KB |
Output is correct |
40 |
Correct |
5 ms |
1288 KB |
Output is correct |
41 |
Correct |
4 ms |
1152 KB |
Output is correct |
42 |
Correct |
6 ms |
1152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1152 KB |
Output is correct |
2 |
Correct |
5 ms |
1428 KB |
Output is correct |
3 |
Correct |
6 ms |
1280 KB |
Output is correct |
4 |
Correct |
10 ms |
1708 KB |
Output is correct |
5 |
Correct |
7 ms |
1564 KB |
Output is correct |
6 |
Correct |
6 ms |
1692 KB |
Output is correct |
7 |
Correct |
7 ms |
1564 KB |
Output is correct |
8 |
Correct |
7 ms |
1564 KB |
Output is correct |
9 |
Correct |
19 ms |
3464 KB |
Output is correct |
10 |
Correct |
25 ms |
3444 KB |
Output is correct |
11 |
Correct |
30 ms |
3468 KB |
Output is correct |
12 |
Correct |
7 ms |
1152 KB |
Output is correct |
13 |
Correct |
4 ms |
1152 KB |
Output is correct |
14 |
Correct |
4 ms |
1288 KB |
Output is correct |
15 |
Correct |
4 ms |
1476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
54 ms |
4196 KB |
Output is correct |
2 |
Correct |
75 ms |
4212 KB |
Output is correct |
3 |
Correct |
54 ms |
4220 KB |
Output is correct |
4 |
Correct |
40 ms |
3112 KB |
Output is correct |
5 |
Partially correct |
45 ms |
3328 KB |
Partially correct |
6 |
Partially correct |
37 ms |
3200 KB |
Partially correct |
7 |
Correct |
38 ms |
3200 KB |
Output is correct |
8 |
Correct |
39 ms |
2992 KB |
Output is correct |
9 |
Correct |
45 ms |
3072 KB |
Output is correct |
10 |
Correct |
33 ms |
3076 KB |
Output is correct |
11 |
Correct |
28 ms |
2948 KB |
Output is correct |
12 |
Correct |
34 ms |
2736 KB |
Output is correct |
13 |
Partially correct |
39 ms |
2820 KB |
Partially correct |
14 |
Partially correct |
28 ms |
2932 KB |
Partially correct |
15 |
Correct |
34 ms |
2952 KB |
Output is correct |
16 |
Correct |
48 ms |
2964 KB |
Output is correct |
17 |
Correct |
38 ms |
2956 KB |
Output is correct |
18 |
Correct |
34 ms |
2900 KB |
Output is correct |
19 |
Partially correct |
34 ms |
2884 KB |
Partially correct |
20 |
Correct |
17 ms |
3116 KB |
Output is correct |
21 |
Correct |
24 ms |
3208 KB |
Output is correct |
22 |
Correct |
31 ms |
3216 KB |
Output is correct |
23 |
Correct |
35 ms |
3200 KB |
Output is correct |
24 |
Correct |
34 ms |
3188 KB |
Output is correct |
25 |
Correct |
31 ms |
3164 KB |
Output is correct |
26 |
Correct |
34 ms |
3220 KB |
Output is correct |
27 |
Correct |
34 ms |
3080 KB |
Output is correct |
28 |
Correct |
34 ms |
3220 KB |
Output is correct |
29 |
Correct |
31 ms |
3048 KB |
Output is correct |
30 |
Correct |
33 ms |
3068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
58 ms |
4436 KB |
Output is correct |
2 |
Correct |
60 ms |
4344 KB |
Output is correct |
3 |
Correct |
67 ms |
4280 KB |
Output is correct |
4 |
Correct |
41 ms |
2968 KB |
Output is correct |
5 |
Incorrect |
55 ms |
3464 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |