# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
401810 | timmyfeng | Amusement Park (JOI17_amusement_park) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
void Joi(int n, int m, vector<int> a, vector<int> b, long long x, int t) {
vector<vector<int>> adj(n);
for (int i = 0; i < m; ++i) {
adj[a[i]].push_back(b[i]);
adj[b[i]].push_back(a[i]);
}
vector<bool> visited(n);
auto dfs = [&](int u, auto &self) -> void {
MessageBoard(u, x % 2);
x /= 2;
visited[u] = true;
for (auto c : adj[u]) {
if (!visited[c]) {
self(c, self);
}
}
};
dfs(1, dfs);
}
#include <bits/stdc++.h>
using namespace std;
const int L = 60;
long long Ioi(int n, int m, vector<int> a, vector<int> b, int p, int v, int t) {
vector<vector<int>> adj(n);
for (int i = 0; i < m; ++i) {
adj[a[i]].push_back(b[i]);
adj[b[i]].push_back(a[i]);
}
vector<int> path;
vector<bool> visited(n);
auto dfs_find = [&](int u, auto &self) -> bool {
visited[u] = true;
if (u == 1) {
return true;
}
for (auto c : adj[u]) {
if (!visited[c] && self(c, self)) {
path.push_back(c);
return true;
}
}
return false;
};
dfs_find(p, dfs_find);
reverse(path.begin(), path.end());
for (auto u : path) {
v = Move(u);
}
int i = 0;
long long ans = 0;
visited.assign(n, false);
auto dfs_read = [&](int u, auto &self) -> bool {
ans |= (long long) v << i;
if (++i == L) {
return true;
}
visited[u] = true;
for (auto c : adj[u]) {
if (!visited[c]) {
v = Move(c);
if (self(c, self)) {
return true;
}
v = Move(u);
}
}
};
dfs_read(1, dfs_read);
return ans;
}