#include "Joi.h"
#include <vector>
#include <map>
using namespace std;
static vector<vector<int>> adj;
static vector<int> ord;
static vector<int> vis;
static vector<bool> seen;
static void dfs(int at) {
seen[at] = true;
vis.push_back(at);
ord.push_back(at);
for (int it : adj[at]) {
if (seen[it]) continue;
dfs(it);
ord.push_back(at);
}
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
adj.resize(N);
seen.resize(N);
for (int i = 0; i < M; i ++) {
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
dfs(0);
ord.pop_back();
for(int i = 0; i < N - 60; i++){
int b = (i % 60);
MessageBoard(vis[i], (X >> b) & 1);
}
for(int i = N - 60; i < N; i++){
int b = i - (N - 60);
MessageBoard(vis[i], (X >> b) & 1);
}
}
#include "Ioi.h"
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
using namespace std;
static vector<vector<int>> adj;
static vector<int> ord;
static vector<int> vis;
static vector<bool> seen;
static void dfs(int at) {
seen[at] = true;
vis.push_back(at);
ord.push_back(at);
for (int it : adj[at]) {
if (seen[it]) continue;
dfs(it);
ord.push_back(at);
}
}
static map<int, int> bits;
static map<int, int> bit;
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
adj.resize(N);
seen.resize(N);
for (int i = 0; i < M; i ++) {
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
dfs(0);
ord.pop_back();
for(int i = 0; i < N - 60; i++){
int b = (i % 60);
bit[vis[i]] = b;
}
for(int i = N - 60; i < N; i++){
int b = i - (N - 60);
bit[vis[i]] = b;
}
int idx = find(vis.begin(), vis.end(), P) - vis.begin();
int d = 1;
if (idx < N - 60) d = -1;
int at = find(ord.begin(), ord.end(), P) - ord.begin();
while (bits.size() != 60) {
at = (at + d + ord.size()) % ord.size();
cerr << "go to " << ord[at] << " get bit " << bit[ord[at]] << endl;
bits[bit[ord[at]]] = Move(ord[at]);
}
long long X = 0;
for (int i = 0; i < 60; ++i) {
X |= (long long)bits[i] << i;
}
return X;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
616 KB |
Output is correct |
2 |
Correct |
3 ms |
628 KB |
Output is correct |
3 |
Correct |
3 ms |
748 KB |
Output is correct |
4 |
Correct |
1 ms |
616 KB |
Output is correct |
5 |
Correct |
3 ms |
612 KB |
Output is correct |
6 |
Correct |
3 ms |
616 KB |
Output is correct |
7 |
Correct |
3 ms |
748 KB |
Output is correct |
8 |
Correct |
3 ms |
620 KB |
Output is correct |
9 |
Correct |
3 ms |
616 KB |
Output is correct |
10 |
Correct |
3 ms |
616 KB |
Output is correct |
11 |
Correct |
5 ms |
952 KB |
Output is correct |
12 |
Correct |
2 ms |
492 KB |
Output is correct |
13 |
Correct |
3 ms |
756 KB |
Output is correct |
14 |
Correct |
3 ms |
764 KB |
Output is correct |
15 |
Correct |
3 ms |
756 KB |
Output is correct |
16 |
Correct |
3 ms |
752 KB |
Output is correct |
17 |
Correct |
3 ms |
752 KB |
Output is correct |
18 |
Correct |
3 ms |
752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
4836 KB |
Output is correct |
2 |
Correct |
32 ms |
4828 KB |
Output is correct |
3 |
Correct |
32 ms |
4888 KB |
Output is correct |
4 |
Correct |
18 ms |
3344 KB |
Output is correct |
5 |
Correct |
20 ms |
3904 KB |
Output is correct |
6 |
Correct |
19 ms |
3764 KB |
Output is correct |
7 |
Correct |
18 ms |
3772 KB |
Output is correct |
8 |
Correct |
19 ms |
3860 KB |
Output is correct |
9 |
Correct |
19 ms |
3892 KB |
Output is correct |
10 |
Correct |
18 ms |
3376 KB |
Output is correct |
11 |
Correct |
18 ms |
3384 KB |
Output is correct |
12 |
Correct |
16 ms |
3112 KB |
Output is correct |
13 |
Correct |
17 ms |
3116 KB |
Output is correct |
14 |
Correct |
18 ms |
3240 KB |
Output is correct |
15 |
Correct |
18 ms |
3368 KB |
Output is correct |
16 |
Correct |
22 ms |
3376 KB |
Output is correct |
17 |
Correct |
19 ms |
3380 KB |
Output is correct |
18 |
Correct |
18 ms |
3396 KB |
Output is correct |
19 |
Correct |
18 ms |
3412 KB |
Output is correct |
20 |
Correct |
35 ms |
4012 KB |
Output is correct |
21 |
Correct |
38 ms |
4036 KB |
Output is correct |
22 |
Correct |
18 ms |
3640 KB |
Output is correct |
23 |
Correct |
19 ms |
3900 KB |
Output is correct |
24 |
Correct |
19 ms |
3684 KB |
Output is correct |
25 |
Correct |
19 ms |
3772 KB |
Output is correct |
26 |
Correct |
22 ms |
3880 KB |
Output is correct |
27 |
Correct |
24 ms |
3832 KB |
Output is correct |
28 |
Correct |
22 ms |
3836 KB |
Output is correct |
29 |
Correct |
17 ms |
3600 KB |
Output is correct |
30 |
Correct |
18 ms |
3652 KB |
Output is correct |
31 |
Correct |
3 ms |
616 KB |
Output is correct |
32 |
Correct |
2 ms |
624 KB |
Output is correct |
33 |
Correct |
3 ms |
748 KB |
Output is correct |
34 |
Correct |
2 ms |
616 KB |
Output is correct |
35 |
Correct |
2 ms |
624 KB |
Output is correct |
36 |
Correct |
2 ms |
616 KB |
Output is correct |
37 |
Correct |
3 ms |
624 KB |
Output is correct |
38 |
Correct |
2 ms |
616 KB |
Output is correct |
39 |
Correct |
3 ms |
488 KB |
Output is correct |
40 |
Correct |
1 ms |
616 KB |
Output is correct |
41 |
Correct |
3 ms |
628 KB |
Output is correct |
42 |
Correct |
3 ms |
624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
616 KB |
Output is correct |
2 |
Correct |
2 ms |
620 KB |
Output is correct |
3 |
Correct |
3 ms |
616 KB |
Output is correct |
4 |
Correct |
4 ms |
1160 KB |
Output is correct |
5 |
Correct |
4 ms |
1152 KB |
Output is correct |
6 |
Correct |
4 ms |
1156 KB |
Output is correct |
7 |
Correct |
4 ms |
1160 KB |
Output is correct |
8 |
Correct |
4 ms |
1156 KB |
Output is correct |
9 |
Correct |
18 ms |
4536 KB |
Output is correct |
10 |
Correct |
16 ms |
4668 KB |
Output is correct |
11 |
Correct |
15 ms |
4664 KB |
Output is correct |
12 |
Correct |
3 ms |
488 KB |
Output is correct |
13 |
Correct |
2 ms |
632 KB |
Output is correct |
14 |
Correct |
1 ms |
496 KB |
Output is correct |
15 |
Correct |
2 ms |
488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
4908 KB |
Output is correct |
2 |
Partially correct |
30 ms |
4852 KB |
Partially correct |
3 |
Partially correct |
33 ms |
4848 KB |
Partially correct |
4 |
Partially correct |
22 ms |
3348 KB |
Partially correct |
5 |
Correct |
22 ms |
4264 KB |
Output is correct |
6 |
Correct |
18 ms |
3880 KB |
Output is correct |
7 |
Correct |
18 ms |
3924 KB |
Output is correct |
8 |
Correct |
18 ms |
3644 KB |
Output is correct |
9 |
Correct |
18 ms |
3620 KB |
Output is correct |
10 |
Correct |
18 ms |
3376 KB |
Output is correct |
11 |
Correct |
18 ms |
3392 KB |
Output is correct |
12 |
Partially correct |
16 ms |
3112 KB |
Partially correct |
13 |
Correct |
24 ms |
3116 KB |
Output is correct |
14 |
Correct |
20 ms |
3248 KB |
Output is correct |
15 |
Correct |
18 ms |
3384 KB |
Output is correct |
16 |
Partially correct |
24 ms |
3356 KB |
Partially correct |
17 |
Partially correct |
18 ms |
3376 KB |
Partially correct |
18 |
Partially correct |
18 ms |
3392 KB |
Partially correct |
19 |
Correct |
19 ms |
3448 KB |
Output is correct |
20 |
Incorrect |
36 ms |
4024 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
4812 KB |
Output is correct |
2 |
Correct |
28 ms |
4824 KB |
Output is correct |
3 |
Incorrect |
37 ms |
4908 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |