#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
const int BITS = 60;
void Joi(int N, int M, int A[], int B[], long long X, int T) {
vector<vector<int>> g(N);
vector<int> color(N);
for (int i = 0; i < M; i++) {
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
vector<int> numBits(BITS);
for (int i = 0; i < BITS; i++) {
if (X & (1LL << i)) {
numBits[i] = 1;
} else {
numBits[i] = 0;
}
}
vector<bool> seen;
int cntSeen;
function<void(int, int)> explore = [&] (int a, int p) {
assert(cntSeen + 1 < BITS);
assert(!seen[color[a]]);
cntSeen++;
seen[color[a]] = 1;
for (auto &b : g[a]) {
if (b != p && cntSeen + 1 < BITS && !seen[color[b]]) {
explore(b, a);
}
}
};
vector<int> subSize(N);
function<void(int, int)> dfsColor = [&] (int a, int p) {
/// color the kids first
subSize[a] = 1;
for (auto &b : g[a]) {
if (b != p) {
dfsColor(b, a);
subSize[a] += subSize[b];
}
}
cntSeen = 0;
seen.clear();
for (int i = 0; i < BITS; i++) {
seen.push_back(0);
}
for (auto &b : g[a]) {
if (b != p && cntSeen + 1 < BITS && !seen[color[b]]) {
explore(b, a);
}
}
color[a] = -1;
assert(cntSeen < BITS);
for (int j = 0; j < BITS; j++) {
if (!seen[j]) {
color[a] = j;
break;
}
}
assert(color[a] != -1);
};
dfsColor(0, -1);
for(int i = 0; i < N; i++){
MessageBoard(i, numBits[color[i]]);
}
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
const int BITS = 60;
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
vector<vector<int>> g(N);
vector<int> color(N);
vector<int> parrent(N);
for (int i = 0; i < M; i++) {
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
vector<int> numBits(BITS, -1);
int needBits = BITS;
vector<bool> seen;
int cntSeen;
function<void(int, int)> explore = [&] (int a, int p) {
assert(cntSeen + 1 < BITS);
assert(!seen[color[a]]);
cntSeen++;
seen[color[a]] = 1;
for (auto &b : g[a]) {
if (b != p && cntSeen + 1 < BITS && !seen[color[b]]) {
explore(b, a);
}
}
};
vector<int> subSize(N);
function<void(int, int)> dfsColor = [&] (int a, int p) {
parrent[a] = p;
/// color the kids first
subSize[a] = 1;
for (auto &b : g[a]) {
if (b != p) {
dfsColor(b, a);
subSize[a] += subSize[b];
}
}
cntSeen = 0;
seen.clear();
for (int i = 0; i < BITS; i++) {
seen.push_back(0);
}
for (auto &b : g[a]) {
if (b != p && cntSeen + 1 < BITS && !seen[color[b]]) {
explore(b, a);
}
}
color[a] = -1;
assert(cntSeen < BITS);
for (int j = 0; j < BITS; j++) {
if (!seen[j]) {
color[a] = j;
break;
}
}
assert(color[a] != -1);
};
dfsColor(0, -1);
function<void(int, int)> run = [&] (int a, int p) {
assert(numBits[color[a]] == -1);
numBits[color[a]] = V;
needBits--;
if (needBits == 0) {
return;
}
for (auto &b : g[a]) {
if (b != p && numBits[color[b]] == -1) {
V = Move(b);
run(b, a);
if (needBits == 0) {
return;
}
V = Move(a);
}
}
};
run(P, -1);
long long theNum = 0;
for (int i = 0; i < BITS; i++) {
if (numBits[i]) {
theNum += (1LL << i);
}
}
return theNum;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
592 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
146 ms |
262148 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
620 KB |
Output is correct |
4 |
Correct |
6 ms |
1296 KB |
Output is correct |
5 |
Correct |
6 ms |
1316 KB |
Output is correct |
6 |
Correct |
6 ms |
1312 KB |
Output is correct |
7 |
Correct |
6 ms |
1404 KB |
Output is correct |
8 |
Correct |
7 ms |
1316 KB |
Output is correct |
9 |
Correct |
34 ms |
4728 KB |
Output is correct |
10 |
Correct |
37 ms |
4956 KB |
Output is correct |
11 |
Correct |
34 ms |
4752 KB |
Output is correct |
12 |
Correct |
1 ms |
536 KB |
Output is correct |
13 |
Correct |
1 ms |
500 KB |
Output is correct |
14 |
Correct |
1 ms |
568 KB |
Output is correct |
15 |
Correct |
0 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
154 ms |
262148 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
167 ms |
262148 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |