#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
struct TREE {
vector<pii> edge;
int getleaf(int x) {
map<int, int> deg;
for(auto& it: edge) {
int x, y; tie(x, y) = it;
++deg[x]; ++deg[y];
}
int ret;
for(auto& it: deg) if(it.second == 1 && it.first != x) ret = it.first;
return ret;
}
};
static TREE change(TREE T, int d, int a, int b) {
TREE ret;
for(auto& it: T.edge) if(it.first != d && it.second != d) ret.edge.push_back(it);
ret.edge.push_back({a, b});
return ret;
}
static TREE T[10009];
static int sid[10009], num[10009], c = 1;
static vector<int> adj[10009];
static bool vs[10009];
static int d = 0;
static void dfs(int x) {
num[x] = d++; sid[x] = 1; vs[x] = 1;
for(auto& it: adj[x]) if(!vs[it] && d < 60) {
T[1].edge.push_back({x, it});
dfs(it);
}
}
static void go(int x, int p) {
vs[x] = 1;
if(sid[x] == 0) {
sid[x] = ++c;
int del = T[sid[p]].getleaf(p);
num[x] = num[del];
T[c] = change(T[sid[p]], del, p, x);
}
for(auto& it: adj[x]) if(!vs[it]) go(it, x);
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
for(int i=0; i<M; i++) {
int u = A[i], v = B[i];
adj[u].push_back(v);
adj[v].push_back(u);
}
dfs(0);
memset(vs, 0, sizeof(vs));
go(0, 0);
for(int i=0; i<N; i++) MessageBoard(i, (X >> num[i]) & 1);
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
struct TREE {
vector<pii> edge;
int getleaf(int x) {
map<int, int> deg;
for(auto& it: edge) {
int x, y; tie(x, y) = it;
++deg[x]; ++deg[y];
}
int ret;
for(auto& it: deg) if(it.second == 1 && it.first != x) ret = it.first;
return ret;
}
};
static TREE change(TREE T, int d, int a, int b) {
TREE ret;
for(auto& it: T.edge) if(it.first != d && it.second != d) ret.edge.push_back(it);
ret.edge.push_back({a, b});
return ret;
}
static TREE T[10009];
static int sid[10009], num[10009], c = 1;
static vector<int> adj[10009];
static bool vs[10009];
static int d = 0;
static void dfs(int x) {
num[x] = d++; sid[x] = 1; vs[x] = 1;
for(auto& it: adj[x]) if(!vs[it] && d < 60) {
T[1].edge.push_back({x, it});
dfs(it);
}
}
static void go(int x, int p) {
vs[x] = 1;
if(sid[x] == 0) {
sid[x] = ++c;
int del = T[sid[p]].getleaf(p);
num[x] = num[del];
T[c] = change(T[sid[p]], del, p, x);
}
for(auto& it: adj[x]) if(!vs[it]) go(it, x);
}
static long long ret;
static bool vis[10009];
static void getans(int tid, int now, int x, int par) {
// printf("tid: %d, now: %d, x: %d, par: %d, num[now]: %d\n", tid, now, x, par, num[now]);
vis[now] = 1;
ret |= (x << num[now]);
for(auto& it: T[tid].edge) {
int u, v; tie(u, v) = it;
if(v == now) swap(u, v);
if(u == now && !vis[v]) getans(tid, v, Move(v), now);
}
if(par != -1) Move(par);
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
for(int i=0; i<M; i++) {
int u = A[i], v = B[i];
adj[u].push_back(v);
adj[v].push_back(u);
}
dfs(0);
memset(vs, 0, sizeof(vs));
go(0, 0);
getans(sid[V], P, V, -1);
return ret;
}
Compilation message
Joi.cpp: In function 'void go(int, int)':
Joi.cpp:23:41: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
for(auto& it: T.edge) if(it.first != d && it.second != d) ret.edge.push_back(it);
~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
Joi.cpp:15:7: note: 'ret' was declared here
int ret;
^~~
Ioi.cpp: In function 'void go(int, int)':
Ioi.cpp:23:41: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
for(auto& it: T.edge) if(it.first != d && it.second != d) ret.edge.push_back(it);
~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
Ioi.cpp:15:7: note: 'ret' was declared here
int ret;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
2008 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
232 ms |
16772 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
1780 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
232 ms |
16892 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
230 ms |
16640 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |