#include "Joi.h"
#include <vector>
#include <algorithm>
using ll = long long;
const int NMAX = 10'000;
std::vector<int> g[NMAX + 1];
int value[NMAX + 1];
bool vis[NMAX + 1];
std::vector<int> order;
void dfs(int u) {
order.push_back(u);
vis[u] = true;
for (const auto &v : g[u]) {
if (!vis[v]) {
dfs(v);
}
}
}
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++) {
std::sort(g[i].begin(), g[i].end());
}
dfs(0);
for (int i = 0; i < 60; i++) {
value[order[i]] = ((ll) X >> i) & 1LL;
}
for (int i = 0; i < n; i++) {
MessageBoard(i, value[i]);
}
}
#include "Ioi.h"
#include <vector>
#include <algorithm>
using ll = long long;
const int NMAX = 10'000;
std::vector<int> g[NMAX + 1];
int value[NMAX + 1];
bool vis[NMAX + 1];
int parent[NMAX + 1];
std::vector<int> order;
void dfs(int u) {
order.push_back(u);
vis[u] = true;
for (const auto &v : g[u]) {
parent[v] = u;
if (!vis[v]) {
dfs(v);
}
}
}
bool hasSon(int u, int v) { // v e fiu al lui u?
for (const auto &w : g[u]) {
if (v == w) {
return true;
}
}
return false;
}
long long Ioi(int n, int m, int a[], int b[], int P, int V, 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++) {
std::sort(g[i].begin(), g[i].end());
}
dfs(0);
int u = P;
ll answer = 0;
while (u != 0) {
u = parent[u];
answer = Move(u);
}
for (int i = 1; i < 60; i++) {
while (!hasSon(u, order[i])) {
u = parent[u];
}
if (Move(order[i])) {
answer |= (1LL << i);
u = order[i];
}
}
return answer;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1308 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
4788 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
1368 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
4844 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
4648 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |