#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
/* sorry, this is the bare minimum :'( */
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) begin(v), end(v)
#define sz(v) (int)(v).size()
#define fi first
#define se second
const int N = 1e5 + 5;
namespace {
vi t[N], g[N];
int vis[N];
int idx[N], done[N];
vi sub[N];
int cnt = 0;
void dfs0(int u) {
vis[u] = 1;
for(int v : g[u]) if(!vis[v]) {
t[u].emplace_back(v);
t[v].emplace_back(u);
dfs0(v);
}
}
void trace_subtree(int u, vi& subtree) {
vis[u] = 1;
cnt++;
subtree.emplace_back(u);
for(int v : t[u]) if(!vis[v] and cnt < 60) {
trace_subtree(v, subtree);
}
}
}
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]].emplace_back(B[i]);
g[B[i]].emplace_back(A[i]);
}
memset(idx, -1, sizeof idx);
dfs0(0);
memset(vis, 0, sizeof vis);
// for(int x : t[0]) cout << x << ' '; cout << endl;
for(int i = 0; i < n; ++i) if(!~idx[i]) {
// cout << "i = " << i << endl;
vi subtree;
trace_subtree(i, subtree);
for(int u : subtree)
vis[u] = 0;
for(int u : subtree) {
if(~idx[u]) vis[idx[u]] = 1;
}
vi unused;
for(int i = 0; i < 60; ++i) {
if(!vis[i]) unused.emplace_back(i);
}
// for(int x : unused) cout << x << ' '; cout << endl;
for(int u : subtree) {
if(~idx[u]) vis[idx[u]] = 0;
}
for(int u : subtree) {
if(!~idx[u]) {
idx[u] = unused.back();
unused.pop_back();
sub[u] = subtree;
}
}
}
for(int i = 0; i < n; ++i) {
// cout << i << ' ' << idx[i] << endl;
MessageBoard(i, X >> idx[i] & 1);
}
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
/* sorry, this is the bare minimum :'( */
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) begin(v), end(v)
#define sz(v) (int)(v).size()
#define fi first
#define se second
const int N = 1e5 + 5;
namespace {
vi g[N];
int vis[N], rnk[N];
int cnt = 0;
vi tour;
void dfs(int u) {
vis[u] = 1;
rnk[u] = cnt++;
tour.emplace_back(u);
for(int v : g[u]) if(!vis[v]) {
dfs(v);
tour.emplace_back(u);
}
}
}
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]].emplace_back(B[i]);
g[B[i]].emplace_back(A[i]);
}
memset(vis, 0, sizeof vis);
dfs(0);
tour.pop_back();
ll ret = ll(V) << (rnk[P] % 60);
int st;
for(int i = 0; ; ++i) {
if(tour[i] == P) {
st = i;
break;
}
}
// int st = int(find(all(tour), P) - tour.begin());
for(int _ = 0, i = (st+1) % sz(tour); _ < 120; i = (i+1) % sz(tour), ++_) {
ret |= ll(Move(tour[i])) << (rnk[tour[i]] % 60);
}
return ret;
}
Compilation message
Joi.cpp:19:15: warning: '{anonymous}::done' defined but not used [-Wunused-variable]
19 | int idx[N], done[N];
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
11372 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
16020 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
11240 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
15660 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
15620 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |