#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define mp make_pair
#define xx first
#define yy second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(x) x.begin(),x.end()
#define ff(i,a,b) for (int i = a; i < b; i++)
#define fff(i,a,b) for (int i = a; i <= b; i++)
#define bff(i,a,b) for (int i = b-1; i >= a; i--)
#define bfff(i,a,b) for (int i = b; i >= a; i--)
using namespace std;
long double typedef ld;
unsigned int typedef ui;
long long int typedef li;
pair<int,int> typedef pii;
pair<li,li> typedef pli;
pair<ld,ld> typedef pld;
vector<vector<int>> typedef graph;
unsigned long long int typedef ull;
//const int mod = 998244353;
const int mod = 1000000007;
//Note to self: Check for overflow
#include "Joi.h"
namespace joi
{
int up[10004];
int Up(int x)
{
if (up[x]<0) return x;
return up[x]=Up(up[x]);
}
void build(int n)
{
ff(i,0,n) up[i]=-1;
}
bool dsu(int a, int b)
{
a=Up(a),b=Up(b);
if (a==b) return false;
if (up[a]<up[b]) swap(a,b);
up[b]+=up[a],up[a]=b;
return true;
}
bool broj[60];
graph g(10004);
int tb=0;
void dfs(int p, int q)
{
MessageBoard(p,broj[tb++]);
if (tb==60) tb=0;
for (auto it : g[p]) if (it!=q) dfs(it,p);
}
void solve(int n, int m, int A[], int B[], li x)
{
build(n);
ff(i,0,m) if (dsu(A[i],B[i])) g[A[i]].pb(B[i]),g[B[i]].pb(A[i]);
ff(i,0,60) broj[i]=((x>>i)&1);
dfs(0,-1);
}
}
using namespace joi;
void Joi(int N, int M, int A[], int B[], long long X, int T)
{
solve(N,M,A,B,X);
}
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define mp make_pair
#define xx first
#define yy second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(x) x.begin(),x.end()
#define ff(i,a,b) for (int i = a; i < b; i++)
#define fff(i,a,b) for (int i = a; i <= b; i++)
#define bff(i,a,b) for (int i = b-1; i >= a; i--)
#define bfff(i,a,b) for (int i = b; i >= a; i--)
using namespace std;
long double typedef ld;
unsigned int typedef ui;
long long int typedef li;
pair<int,int> typedef pii;
pair<li,li> typedef pli;
pair<ld,ld> typedef pld;
vector<vector<int>> typedef graph;
unsigned long long int typedef ull;
//const int mod = 998244353;
const int mod = 1000000007;
//Note to self: Check for overflow
#include "Ioi.h"
namespace ioi
{
int up[10004];
int Up(int x)
{
if (up[x]<0) return x;
return up[x]=Up(up[x]);
}
void build(int n)
{
ff(i,0,n) up[i]=-1;
}
bool dsu(int a, int b)
{
a=Up(a),b=Up(b);
if (a==b) return false;
if (up[a]<up[b]) swap(a,b);
up[b]+=up[a],up[a]=b;
return true;
}
bool broj[60];
graph g(10004);
bool boja[10004];
int tb=0;
void dfs(int p, int q)
{
boja[p]=tb;
if (tb==60) tb=0;
for (auto it : g[p]) if (it!=q) dfs(it,p);
}
bool uklj[69];
int kolko=0;
li ans=0;
void klizaj(int p, int q)
{
if (kolko==60) return;
int sta=0;
//int sta=Move(p);
if (!uklj[boja[p]])
{
uklj[boja[p]]=1,kolko++;
if (sta) ans|=(1ll<<boja[p]);
}
if (kolko==60) return;
//for (auto it : g[p]) if (it!=q) klizaj(it,p);
if (kolko==60) return;
//if (q!=-1) Move(q);
}
li solve(int n, int m, int A[], int B[], int P, int V)
{
build(n);
ff(i,0,m) if (dsu(A[i],B[i])) g[A[i]].pb(B[i]),g[B[i]].pb(A[i]);
dfs(0,-1);
uklj[boja[P]]=1,kolko++;
if (V) ans|=(1ll<<boja[P]);
for (auto it : g[P]) klizaj(it,P);
return ans;
}
}
using namespace ioi;
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T)
{
return solve(N,M,A,B,P,V);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1044 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
3132 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
1044 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
3084 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
3168 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |