#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, i);
int F = V;
for (int j = 1; j < E.size(); j++) {
F = Move(E[j]);
}
rem += 1LL * F * (1LL << i);
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 |
1392 KB |
Output is correct |
2 |
Correct |
4 ms |
1152 KB |
Output is correct |
3 |
Correct |
4 ms |
1320 KB |
Output is correct |
4 |
Correct |
4 ms |
1392 KB |
Output is correct |
5 |
Correct |
5 ms |
1388 KB |
Output is correct |
6 |
Correct |
6 ms |
1512 KB |
Output is correct |
7 |
Correct |
6 ms |
1284 KB |
Output is correct |
8 |
Correct |
4 ms |
1292 KB |
Output is correct |
9 |
Correct |
4 ms |
1292 KB |
Output is correct |
10 |
Correct |
4 ms |
1288 KB |
Output is correct |
11 |
Correct |
8 ms |
1712 KB |
Output is correct |
12 |
Correct |
4 ms |
1288 KB |
Output is correct |
13 |
Correct |
5 ms |
1532 KB |
Output is correct |
14 |
Correct |
6 ms |
1292 KB |
Output is correct |
15 |
Correct |
5 ms |
1408 KB |
Output is correct |
16 |
Correct |
5 ms |
1292 KB |
Output is correct |
17 |
Correct |
5 ms |
1420 KB |
Output is correct |
18 |
Correct |
6 ms |
1376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
68 ms |
4212 KB |
Output is correct |
2 |
Correct |
63 ms |
4500 KB |
Output is correct |
3 |
Correct |
63 ms |
4380 KB |
Output is correct |
4 |
Correct |
42 ms |
2944 KB |
Output is correct |
5 |
Correct |
47 ms |
3208 KB |
Output is correct |
6 |
Correct |
47 ms |
3204 KB |
Output is correct |
7 |
Correct |
48 ms |
3072 KB |
Output is correct |
8 |
Correct |
49 ms |
3188 KB |
Output is correct |
9 |
Correct |
41 ms |
3208 KB |
Output is correct |
10 |
Correct |
28 ms |
3000 KB |
Output is correct |
11 |
Correct |
28 ms |
2956 KB |
Output is correct |
12 |
Correct |
30 ms |
2960 KB |
Output is correct |
13 |
Correct |
32 ms |
2792 KB |
Output is correct |
14 |
Correct |
28 ms |
2852 KB |
Output is correct |
15 |
Correct |
40 ms |
3076 KB |
Output is correct |
16 |
Correct |
43 ms |
2936 KB |
Output is correct |
17 |
Correct |
37 ms |
2944 KB |
Output is correct |
18 |
Correct |
47 ms |
3012 KB |
Output is correct |
19 |
Correct |
36 ms |
2944 KB |
Output is correct |
20 |
Correct |
28 ms |
3200 KB |
Output is correct |
21 |
Correct |
20 ms |
3200 KB |
Output is correct |
22 |
Correct |
38 ms |
3072 KB |
Output is correct |
23 |
Correct |
35 ms |
3204 KB |
Output is correct |
24 |
Correct |
38 ms |
3208 KB |
Output is correct |
25 |
Correct |
40 ms |
3208 KB |
Output is correct |
26 |
Correct |
41 ms |
3068 KB |
Output is correct |
27 |
Correct |
41 ms |
3200 KB |
Output is correct |
28 |
Correct |
37 ms |
3072 KB |
Output is correct |
29 |
Correct |
34 ms |
2836 KB |
Output is correct |
30 |
Correct |
35 ms |
3060 KB |
Output is correct |
31 |
Correct |
6 ms |
1280 KB |
Output is correct |
32 |
Correct |
6 ms |
1300 KB |
Output is correct |
33 |
Correct |
6 ms |
1420 KB |
Output is correct |
34 |
Correct |
5 ms |
1152 KB |
Output is correct |
35 |
Correct |
4 ms |
1288 KB |
Output is correct |
36 |
Correct |
5 ms |
1152 KB |
Output is correct |
37 |
Correct |
5 ms |
1288 KB |
Output is correct |
38 |
Correct |
5 ms |
1280 KB |
Output is correct |
39 |
Correct |
5 ms |
1288 KB |
Output is correct |
40 |
Correct |
6 ms |
1288 KB |
Output is correct |
41 |
Correct |
5 ms |
1152 KB |
Output is correct |
42 |
Correct |
4 ms |
1388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1280 KB |
Output is correct |
2 |
Correct |
5 ms |
1292 KB |
Output is correct |
3 |
Correct |
6 ms |
1156 KB |
Output is correct |
4 |
Correct |
8 ms |
1624 KB |
Output is correct |
5 |
Correct |
8 ms |
1564 KB |
Output is correct |
6 |
Correct |
7 ms |
1804 KB |
Output is correct |
7 |
Correct |
8 ms |
1544 KB |
Output is correct |
8 |
Correct |
8 ms |
1568 KB |
Output is correct |
9 |
Correct |
26 ms |
3472 KB |
Output is correct |
10 |
Correct |
23 ms |
3472 KB |
Output is correct |
11 |
Correct |
23 ms |
3476 KB |
Output is correct |
12 |
Correct |
4 ms |
1152 KB |
Output is correct |
13 |
Correct |
4 ms |
1152 KB |
Output is correct |
14 |
Correct |
4 ms |
1148 KB |
Output is correct |
15 |
Correct |
4 ms |
1280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
69 ms |
4316 KB |
Output is correct |
2 |
Correct |
69 ms |
4348 KB |
Output is correct |
3 |
Correct |
59 ms |
4228 KB |
Output is correct |
4 |
Correct |
45 ms |
2952 KB |
Output is correct |
5 |
Partially correct |
48 ms |
3364 KB |
Partially correct |
6 |
Partially correct |
47 ms |
3280 KB |
Partially correct |
7 |
Correct |
38 ms |
3080 KB |
Output is correct |
8 |
Correct |
37 ms |
2996 KB |
Output is correct |
9 |
Correct |
37 ms |
3036 KB |
Output is correct |
10 |
Correct |
27 ms |
3100 KB |
Output is correct |
11 |
Correct |
37 ms |
3044 KB |
Output is correct |
12 |
Correct |
44 ms |
2864 KB |
Output is correct |
13 |
Partially correct |
34 ms |
2800 KB |
Partially correct |
14 |
Partially correct |
33 ms |
2688 KB |
Partially correct |
15 |
Correct |
47 ms |
2944 KB |
Output is correct |
16 |
Correct |
34 ms |
2944 KB |
Output is correct |
17 |
Correct |
46 ms |
3048 KB |
Output is correct |
18 |
Correct |
40 ms |
2944 KB |
Output is correct |
19 |
Partially correct |
43 ms |
2936 KB |
Partially correct |
20 |
Correct |
20 ms |
3188 KB |
Output is correct |
21 |
Correct |
23 ms |
3224 KB |
Output is correct |
22 |
Correct |
40 ms |
3088 KB |
Output is correct |
23 |
Correct |
39 ms |
3088 KB |
Output is correct |
24 |
Correct |
34 ms |
3224 KB |
Output is correct |
25 |
Correct |
34 ms |
3088 KB |
Output is correct |
26 |
Correct |
33 ms |
3224 KB |
Output is correct |
27 |
Correct |
36 ms |
3328 KB |
Output is correct |
28 |
Correct |
32 ms |
3224 KB |
Output is correct |
29 |
Correct |
27 ms |
2944 KB |
Output is correct |
30 |
Correct |
30 ms |
3076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
4188 KB |
Output is correct |
2 |
Correct |
68 ms |
4412 KB |
Output is correct |
3 |
Correct |
62 ms |
4404 KB |
Output is correct |
4 |
Correct |
37 ms |
2968 KB |
Output is correct |
5 |
Incorrect |
46 ms |
3480 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |