#include "Joi.h"
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;
void Joi(int n, int m, int u[], int v[], ll x, int t)
{
vector <vector <ll>> A(n);
for (ll i=0; i<n; i++)
A[u[i]].pb(v[i]), A[v[i]].pb(u[i]);
vector <ll> tin(n, -1); ll Time=0;
function <void(ll)> dfs=[&](ll u)
{
tin[u]=Time, Time=(Time+1)%60;
MessageBoard(u, (x>>tin[u])&1);
for (ll v:A[u])
if (tin[v]==-1)
dfs(v);
}; dfs(0);
}
#include "Ioi.h"
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;
ll Ioi(int n, int m, int u[], int v[], int p, int cr, int t)
{
vector <vector <ll>> A(n);
for (ll i=0; i<n; i++)
A[u[i]].pb(v[i]), A[v[i]].pb(u[i]);
ll Time=0, pos=0;
vector <pll> realedge;
vector <ll> order, tin(n, -1);
function <void(ll)> dfs=[&](ll u)
{
if (u==p) pos=order.size(); order.pb(u);
tin[u]=Time, Time=(Time+1)%60;
for (ll v:A[u])
if (tin[v]==-1)
realedge.pb({v, u}), dfs(v);
}; dfs(0);
for (ll i=0; i<n; i++) A[i].clear();
for (auto [u, v]:realedge) A[u].pb(v), A[v].pb(u);
pll best={1e9, 0};
for (ll i=pos; i>=0 && i>pos-60; i--)
{
if (i+60>n) continue;
vector <ll> mark(n, 0), dis(n, 0);
for (ll j=i; j<i+60; j++)
mark[order[j]]=1;
function <void(ll, ll)> dfs1=[&](ll u, ll pa)
{
for (ll v:A[u]) if (v!=pa)
{
dfs1(v, u), mark[u]|=mark[v];
if (mark[v]) dis[u]=max(dis[u], dis[v]+1);
}
}; dfs1(p, -1);
ll cnt=0, Max=0;
for (ll j=0; j<n; j++)
cnt+=mark[j], Max=max(Max, dis[j]);
best=min(best, {(cnt-1)*2-Max, i});
}
assert(best.fi<=120);
vector <ll> mark(n, 0), dis(n, 0), pa(n, -1), ism(n, 0);
for (ll j=best.se; j<best.se+60; j++)
mark[order[j]]=1;
function <void(ll)> dfs1=[&](ll u)
{
for (ll v:A[u]) if (v!=pa[u])
{
pa[v]=u, dfs1(v), mark[u]|=mark[v];
if (mark[v]) dis[u]=max(dis[u], dis[v]+1);
}
}; dfs1(p);
pll Max={0, 0};
for (ll i=0; i<n; i++)
Max=max(Max, {dis[i], i});
ism[Max.se]=1;
while (pa[Max.se]!=-1)
Max.se=pa[Max.se], ism[Max.se]=1;
ll cnt=0, bit[60]={}; bit[tin[p]]=cr;
function <void(ll)> answer=[&](ll u)
{
for (ll i=0; i<A[u].size(); i++)
if (ism[A[u][i]])
{swap(A[u][i], A[u].back()); break;}
for (ll v:A[u])
if (mark[v] && v!=pa[u])
bit[tin[v]]=Move(v), cnt++, answer(v);
if (cnt<best.fi && pa[u]!=-1) bit[tin[pa[u]]]=Move(pa[u]), cnt++;
}; answer(p);
assert(cnt<=120);
ll ans=0;
for (ll i=0; i<60; i++)
if (bit[i]) ans|=1ll<<i;
return ans;
}
Compilation message
Ioi.cpp: In lambda function:
Ioi.cpp:22:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
22 | if (u==p) pos=order.size(); order.pb(u);
| ^~
Ioi.cpp:22:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
22 | if (u==p) pos=order.size(); order.pb(u);
| ^~~~~
Ioi.cpp: In lambda function:
Ioi.cpp:71:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
71 | for (ll i=0; i<A[u].size(); i++)
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
788 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
2268 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
784 KB |
Output is correct |
2 |
Incorrect |
1 ms |
784 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
2268 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
2284 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |