#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;
ord.push_back(at);
int b = (int)bit.size();
bit[at] = b % 60;
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 map<int, int> bits;
static vector<int> par;
static void dfs(int at) {
seen[at] = true;
ord.push_back(at);
int b = (int)bit.size();
bit[at] = b % 60;
for (int it : adj[at]) {
if (seen[it]) continue;
par[it] = at;
dfs(it);
ord.push_back(at);
}
}
static void dfs2(int at) {
for (int it : adj[at]) {
if (bits.count(bit[it]) || it == par[at]) continue;
bits[bit[it]] = Move(it);
dfs2(it);
Move(at);
}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
adj.resize(N);
seen.resize(N);
par.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();
bits[bit[P]] = V;
while (bits.size() != 60) {
dfs2(P);
P = par[P];
if (bits.size() != 60) bits[bit[P]] = Move(P);
}
cerr << "bits: " << bits.size() << endl;
//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] << " 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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
496 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
5484 KB |
Output is correct |
2 |
Correct |
32 ms |
5600 KB |
Output is correct |
3 |
Correct |
32 ms |
5624 KB |
Output is correct |
4 |
Correct |
20 ms |
3636 KB |
Output is correct |
5 |
Correct |
22 ms |
4672 KB |
Output is correct |
6 |
Correct |
24 ms |
4152 KB |
Output is correct |
7 |
Correct |
22 ms |
4236 KB |
Output is correct |
8 |
Correct |
22 ms |
4404 KB |
Output is correct |
9 |
Correct |
22 ms |
4400 KB |
Output is correct |
10 |
Correct |
22 ms |
3664 KB |
Output is correct |
11 |
Correct |
22 ms |
3660 KB |
Output is correct |
12 |
Correct |
19 ms |
3364 KB |
Output is correct |
13 |
Correct |
19 ms |
3372 KB |
Output is correct |
14 |
Correct |
19 ms |
3376 KB |
Output is correct |
15 |
Correct |
20 ms |
3624 KB |
Output is correct |
16 |
Correct |
20 ms |
3652 KB |
Output is correct |
17 |
Correct |
20 ms |
3580 KB |
Output is correct |
18 |
Correct |
23 ms |
3664 KB |
Output is correct |
19 |
Correct |
20 ms |
3628 KB |
Output is correct |
20 |
Correct |
16 ms |
4648 KB |
Output is correct |
21 |
Correct |
16 ms |
4640 KB |
Output is correct |
22 |
Incorrect |
22 ms |
4144 KB |
Wrong Answer [7] |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
624 KB |
Output is correct |
2 |
Correct |
2 ms |
612 KB |
Output is correct |
3 |
Correct |
2 ms |
616 KB |
Output is correct |
4 |
Correct |
4 ms |
1284 KB |
Output is correct |
5 |
Correct |
4 ms |
1288 KB |
Output is correct |
6 |
Correct |
4 ms |
1284 KB |
Output is correct |
7 |
Correct |
4 ms |
1292 KB |
Output is correct |
8 |
Correct |
4 ms |
1284 KB |
Output is correct |
9 |
Correct |
17 ms |
5680 KB |
Output is correct |
10 |
Correct |
17 ms |
5544 KB |
Output is correct |
11 |
Correct |
16 ms |
5696 KB |
Output is correct |
12 |
Correct |
2 ms |
616 KB |
Output is correct |
13 |
Correct |
1 ms |
624 KB |
Output is correct |
14 |
Correct |
1 ms |
616 KB |
Output is correct |
15 |
Correct |
2 ms |
624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
32 ms |
5524 KB |
Partially correct |
2 |
Correct |
32 ms |
5516 KB |
Output is correct |
3 |
Partially correct |
32 ms |
5628 KB |
Partially correct |
4 |
Correct |
20 ms |
3720 KB |
Output is correct |
5 |
Correct |
22 ms |
5180 KB |
Output is correct |
6 |
Correct |
22 ms |
4392 KB |
Output is correct |
7 |
Correct |
22 ms |
4404 KB |
Output is correct |
8 |
Correct |
27 ms |
4004 KB |
Output is correct |
9 |
Correct |
22 ms |
4220 KB |
Output is correct |
10 |
Correct |
23 ms |
3744 KB |
Output is correct |
11 |
Correct |
20 ms |
3704 KB |
Output is correct |
12 |
Correct |
18 ms |
3376 KB |
Output is correct |
13 |
Correct |
19 ms |
3348 KB |
Output is correct |
14 |
Correct |
19 ms |
3324 KB |
Output is correct |
15 |
Correct |
22 ms |
3628 KB |
Output is correct |
16 |
Correct |
19 ms |
3632 KB |
Output is correct |
17 |
Correct |
19 ms |
3608 KB |
Output is correct |
18 |
Correct |
19 ms |
3684 KB |
Output is correct |
19 |
Correct |
22 ms |
3708 KB |
Output is correct |
20 |
Correct |
17 ms |
4728 KB |
Output is correct |
21 |
Correct |
16 ms |
4672 KB |
Output is correct |
22 |
Correct |
22 ms |
4412 KB |
Output is correct |
23 |
Correct |
22 ms |
4288 KB |
Output is correct |
24 |
Correct |
22 ms |
4236 KB |
Output is correct |
25 |
Correct |
22 ms |
4464 KB |
Output is correct |
26 |
Correct |
22 ms |
4412 KB |
Output is correct |
27 |
Correct |
22 ms |
4376 KB |
Output is correct |
28 |
Correct |
22 ms |
4136 KB |
Output is correct |
29 |
Correct |
19 ms |
4120 KB |
Output is correct |
30 |
Correct |
19 ms |
4144 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
5472 KB |
Output is correct |
2 |
Correct |
32 ms |
5504 KB |
Output is correct |
3 |
Correct |
32 ms |
5480 KB |
Output is correct |
4 |
Correct |
20 ms |
3632 KB |
Output is correct |
5 |
Correct |
22 ms |
5224 KB |
Output is correct |
6 |
Correct |
22 ms |
4356 KB |
Output is correct |
7 |
Correct |
22 ms |
4168 KB |
Output is correct |
8 |
Correct |
22 ms |
4348 KB |
Output is correct |
9 |
Correct |
22 ms |
4380 KB |
Output is correct |
10 |
Correct |
22 ms |
3756 KB |
Output is correct |
11 |
Correct |
20 ms |
3620 KB |
Output is correct |
12 |
Correct |
19 ms |
3364 KB |
Output is correct |
13 |
Correct |
19 ms |
3368 KB |
Output is correct |
14 |
Correct |
19 ms |
3416 KB |
Output is correct |
15 |
Correct |
22 ms |
3632 KB |
Output is correct |
16 |
Correct |
19 ms |
3632 KB |
Output is correct |
17 |
Correct |
22 ms |
3704 KB |
Output is correct |
18 |
Correct |
20 ms |
3640 KB |
Output is correct |
19 |
Correct |
20 ms |
3620 KB |
Output is correct |
20 |
Correct |
17 ms |
4740 KB |
Output is correct |
21 |
Correct |
16 ms |
4712 KB |
Output is correct |
22 |
Correct |
22 ms |
4396 KB |
Output is correct |
23 |
Correct |
22 ms |
4220 KB |
Output is correct |
24 |
Correct |
22 ms |
4160 KB |
Output is correct |
25 |
Correct |
22 ms |
4256 KB |
Output is correct |
26 |
Correct |
23 ms |
4156 KB |
Output is correct |
27 |
Correct |
22 ms |
4416 KB |
Output is correct |
28 |
Correct |
22 ms |
4448 KB |
Output is correct |
29 |
Correct |
19 ms |
4180 KB |
Output is correct |
30 |
Correct |
19 ms |
4248 KB |
Output is correct |
31 |
Correct |
2 ms |
616 KB |
Output is correct |
32 |
Correct |
2 ms |
620 KB |
Output is correct |
33 |
Correct |
2 ms |
748 KB |
Output is correct |
34 |
Correct |
2 ms |
616 KB |
Output is correct |
35 |
Correct |
2 ms |
620 KB |
Output is correct |
36 |
Correct |
3 ms |
620 KB |
Output is correct |
37 |
Incorrect |
1 ms |
500 KB |
Wrong Answer [7] |
38 |
Halted |
0 ms |
0 KB |
- |