#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define eb emplace_back
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
static const int MAXN = 2e4 + 6;
static int n, m, comp[MAXN], cnt;
static ll X, sz[MAXN];
static vector < int > g[MAXN];
static bool u[MAXN];
void dfs(int v) {
u[v] = 1;
for (auto to : g[v]) {
if (u[to]) continue;
if (sz[comp[v]] == 60)
comp[to] = ++cnt;
else
comp[to] = comp[v];
MessageBoard(to - 1, (X >> sz[comp[to]]) & 1);
sz[comp[to]]++;
dfs(to);
}
}
void Joi(int _n, int _m, int A[], int B[], long long _x, int _t) {
n = _n, m = _m;
X = _x;
forn(i, 0, m - 1) {
A[i]++, B[i]++;
g[A[i]].eb(B[i]);
g[B[i]].eb(A[i]);
}
cnt = 1;
comp[1] = 1;
sz[comp[1]] = 1;
MessageBoard(0, X & 1);
dfs(1);
}
#ifdef krauch
int main() {
return 0;
}
#endif
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define eb emplace_back
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
static const int MAXN = 2e4 + 6;
static int n, m, comp[MAXN], cnt, par[MAXN];
static ll X, sz[MAXN], lvl[MAXN], ans[66];
static vector < int > g[MAXN];
static bool u[MAXN];
void dfs(int v) {
u[v] = 1;
for (auto to : g[v]) {
if (u[to]) continue;
if (sz[comp[v]] == 60)
comp[to] = ++cnt;
else
comp[to] = comp[v];
lvl[to] = sz[comp[to]];
sz[comp[to]]++;
par[to] = v;
dfs(to);
}
}
void dfs2(int v, int val) {
u[v] = 1;
ans[lvl[v]] |= val;
for (auto to : g[v]) {
if (u[to] || comp[to] != comp[v]) continue;
int toval = Move(to - 1);
dfs2(to, toval);
val = Move(v - 1);
}
}
ll Ioi(int _n, int _m, int A[], int B[], int _p, int _v, int _t) {
n = _n, m = _m;
int st = _p + 1, stval = _v;
forn(i, 0, m - 1) {
A[i]++, B[i]++;
g[A[i]].eb(B[i]);
g[B[i]].eb(A[i]);
}
cnt = 1;
comp[1] = 1;
sz[comp[1]] = 1;
dfs(1);
while (sz[comp[st]] != 60) {
assert(st != 0);
st = par[st];
stval = Move(st - 1);
}
forn(i, 1, n) u[i] = 0;
dfs2(st, stval);
ll res = 0;
forn(i, 0, 60) {
res |= (ans[i] << ll(i));
}
return res;
}
#ifdef krauch
int main() {
return 0;
}
#endif
Compilation message
Ioi.cpp:15:11: warning: 'X' defined but not used [-Wunused-variable]
static ll X, sz[MAXN], lvl[MAXN], ans[66];
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
1632 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
32 ms |
4760 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
4760 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
4936 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
33 ms |
4936 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |