#include "Joi.h"
#include <vector>
#include <map>
using namespace std;
static vector<vector<int>> adj;
static vector<int> ord;
static map<int, int> bit;
static vector<bool> seen;
static void dfs(int at) {
seen[at] = true;
int b = (int)bit.size();
bit[at] = b % 60;
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; i++){
MessageBoard(i, (X >> bit[i]) & 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 map<int, int> bit;
static vector<bool> seen;
static void dfs(int at) {
seen[at] = true;
int b = (int)bit.size();
bit[at] = b % 60;
ord.push_back(at);
for (int it : adj[at]) {
if (seen[it]) continue;
dfs(it);
ord.push_back(at);
}
}
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();
map<int, int> bits;
bits[bit[P]] = V;
int at = find(ord.begin(), ord.end(), P) - ord.begin();
while ((int)bits.size() != 60) {
at = (at + 1) % ord.size();
cerr << "go to " << 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 |
496 KB |
Output is correct |
2 |
Correct |
2 ms |
620 KB |
Output is correct |
3 |
Correct |
3 ms |
620 KB |
Output is correct |
4 |
Correct |
2 ms |
620 KB |
Output is correct |
5 |
Correct |
3 ms |
616 KB |
Output is correct |
6 |
Correct |
2 ms |
620 KB |
Output is correct |
7 |
Correct |
2 ms |
752 KB |
Output is correct |
8 |
Correct |
2 ms |
764 KB |
Output is correct |
9 |
Correct |
3 ms |
756 KB |
Output is correct |
10 |
Correct |
2 ms |
700 KB |
Output is correct |
11 |
Correct |
5 ms |
932 KB |
Output is correct |
12 |
Correct |
2 ms |
496 KB |
Output is correct |
13 |
Correct |
2 ms |
752 KB |
Output is correct |
14 |
Correct |
2 ms |
756 KB |
Output is correct |
15 |
Correct |
2 ms |
756 KB |
Output is correct |
16 |
Correct |
2 ms |
752 KB |
Output is correct |
17 |
Correct |
2 ms |
704 KB |
Output is correct |
18 |
Correct |
2 ms |
752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
5508 KB |
Output is correct |
2 |
Correct |
33 ms |
5500 KB |
Output is correct |
3 |
Correct |
38 ms |
5452 KB |
Output is correct |
4 |
Correct |
22 ms |
3624 KB |
Output is correct |
5 |
Correct |
23 ms |
4528 KB |
Output is correct |
6 |
Correct |
23 ms |
4120 KB |
Output is correct |
7 |
Correct |
22 ms |
4308 KB |
Output is correct |
8 |
Correct |
22 ms |
4340 KB |
Output is correct |
9 |
Correct |
23 ms |
4348 KB |
Output is correct |
10 |
Correct |
20 ms |
3592 KB |
Output is correct |
11 |
Correct |
25 ms |
3624 KB |
Output is correct |
12 |
Correct |
19 ms |
3412 KB |
Output is correct |
13 |
Correct |
19 ms |
3284 KB |
Output is correct |
14 |
Correct |
22 ms |
3376 KB |
Output is correct |
15 |
Correct |
22 ms |
3644 KB |
Output is correct |
16 |
Correct |
22 ms |
3624 KB |
Output is correct |
17 |
Correct |
22 ms |
3628 KB |
Output is correct |
18 |
Correct |
22 ms |
3636 KB |
Output is correct |
19 |
Correct |
22 ms |
3668 KB |
Output is correct |
20 |
Correct |
30 ms |
4672 KB |
Output is correct |
21 |
Correct |
34 ms |
4840 KB |
Output is correct |
22 |
Correct |
22 ms |
4276 KB |
Output is correct |
23 |
Correct |
23 ms |
4604 KB |
Output is correct |
24 |
Correct |
22 ms |
4352 KB |
Output is correct |
25 |
Correct |
23 ms |
4480 KB |
Output is correct |
26 |
Correct |
23 ms |
4576 KB |
Output is correct |
27 |
Correct |
22 ms |
4636 KB |
Output is correct |
28 |
Correct |
23 ms |
4616 KB |
Output is correct |
29 |
Correct |
19 ms |
4312 KB |
Output is correct |
30 |
Correct |
23 ms |
4356 KB |
Output is correct |
31 |
Correct |
2 ms |
620 KB |
Output is correct |
32 |
Correct |
2 ms |
616 KB |
Output is correct |
33 |
Correct |
2 ms |
752 KB |
Output is correct |
34 |
Correct |
2 ms |
704 KB |
Output is correct |
35 |
Correct |
2 ms |
492 KB |
Output is correct |
36 |
Correct |
2 ms |
624 KB |
Output is correct |
37 |
Correct |
2 ms |
628 KB |
Output is correct |
38 |
Correct |
2 ms |
496 KB |
Output is correct |
39 |
Correct |
2 ms |
492 KB |
Output is correct |
40 |
Correct |
3 ms |
704 KB |
Output is correct |
41 |
Correct |
2 ms |
712 KB |
Output is correct |
42 |
Correct |
2 ms |
620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
624 KB |
Output is correct |
2 |
Correct |
2 ms |
624 KB |
Output is correct |
3 |
Correct |
2 ms |
620 KB |
Output is correct |
4 |
Correct |
4 ms |
1280 KB |
Output is correct |
5 |
Correct |
4 ms |
1284 KB |
Output is correct |
6 |
Correct |
4 ms |
1284 KB |
Output is correct |
7 |
Correct |
4 ms |
1284 KB |
Output is correct |
8 |
Correct |
4 ms |
1392 KB |
Output is correct |
9 |
Correct |
18 ms |
5540 KB |
Output is correct |
10 |
Correct |
18 ms |
5544 KB |
Output is correct |
11 |
Correct |
20 ms |
5544 KB |
Output is correct |
12 |
Correct |
2 ms |
496 KB |
Output is correct |
13 |
Correct |
2 ms |
616 KB |
Output is correct |
14 |
Correct |
1 ms |
488 KB |
Output is correct |
15 |
Correct |
1 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
5484 KB |
Output is correct |
2 |
Partially correct |
35 ms |
5504 KB |
Partially correct |
3 |
Partially correct |
39 ms |
5488 KB |
Partially correct |
4 |
Correct |
22 ms |
3640 KB |
Output is correct |
5 |
Partially correct |
23 ms |
5056 KB |
Partially correct |
6 |
Correct |
22 ms |
4272 KB |
Output is correct |
7 |
Correct |
22 ms |
4336 KB |
Output is correct |
8 |
Correct |
22 ms |
3844 KB |
Output is correct |
9 |
Correct |
24 ms |
4152 KB |
Output is correct |
10 |
Correct |
22 ms |
3644 KB |
Output is correct |
11 |
Correct |
20 ms |
3624 KB |
Output is correct |
12 |
Correct |
20 ms |
3396 KB |
Output is correct |
13 |
Correct |
19 ms |
3412 KB |
Output is correct |
14 |
Correct |
20 ms |
3400 KB |
Output is correct |
15 |
Correct |
22 ms |
3636 KB |
Output is correct |
16 |
Correct |
22 ms |
3624 KB |
Output is correct |
17 |
Correct |
22 ms |
3592 KB |
Output is correct |
18 |
Correct |
22 ms |
3664 KB |
Output is correct |
19 |
Correct |
22 ms |
3608 KB |
Output is correct |
20 |
Incorrect |
31 ms |
4664 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
5560 KB |
Output is correct |
2 |
Correct |
33 ms |
5556 KB |
Output is correct |
3 |
Incorrect |
33 ms |
5560 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |