#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;
vector<int> tura;
void dfs(int p, int q)
{
tura.pb(p);
MessageBoard(p,broj[tb++]);
if (tb==60) tb=0;
for (auto it : g[p]) if (it!=q)
{
dfs(it,p);
tura.pb(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);
int boja[10004];
int tb=0;
vector<int> tura;
void dfs(int p, int q)
{
tura.pb(p);
boja[p]=tb++;
if (tb==60) tb=0;
for (auto it : g[p]) if (it!=q)
{
dfs(it,p);
tura.pb(p);
}
}
bool uklj[69];
int kolko=0;
li ans=0;
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]);
int id=0;
while (tura[id]!=P) id++;
while (true)
{
++id; if (id==(int)tura.size()) id=1; int p=tura[id];
int sta=Move(p);
if (!uklj[boja[p]])
{
uklj[boja[p]]=1,kolko++;
if (sta) ans|=(1ll<<boja[p]);
if (kolko==60) break;
}
}
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 |
Correct |
2 ms |
1044 KB |
Output is correct |
2 |
Correct |
2 ms |
1168 KB |
Output is correct |
3 |
Correct |
2 ms |
1168 KB |
Output is correct |
4 |
Correct |
2 ms |
1044 KB |
Output is correct |
5 |
Correct |
2 ms |
1044 KB |
Output is correct |
6 |
Correct |
2 ms |
1036 KB |
Output is correct |
7 |
Correct |
2 ms |
1296 KB |
Output is correct |
8 |
Correct |
2 ms |
1172 KB |
Output is correct |
9 |
Correct |
2 ms |
1176 KB |
Output is correct |
10 |
Correct |
2 ms |
1048 KB |
Output is correct |
11 |
Correct |
5 ms |
1340 KB |
Output is correct |
12 |
Correct |
2 ms |
1036 KB |
Output is correct |
13 |
Correct |
2 ms |
1176 KB |
Output is correct |
14 |
Correct |
2 ms |
1168 KB |
Output is correct |
15 |
Correct |
2 ms |
1168 KB |
Output is correct |
16 |
Correct |
2 ms |
1308 KB |
Output is correct |
17 |
Correct |
2 ms |
1168 KB |
Output is correct |
18 |
Correct |
2 ms |
1168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
3596 KB |
Output is correct |
2 |
Correct |
29 ms |
3660 KB |
Output is correct |
3 |
Correct |
20 ms |
3668 KB |
Output is correct |
4 |
Correct |
13 ms |
3164 KB |
Output is correct |
5 |
Correct |
13 ms |
3584 KB |
Output is correct |
6 |
Correct |
13 ms |
3412 KB |
Output is correct |
7 |
Correct |
13 ms |
3416 KB |
Output is correct |
8 |
Correct |
13 ms |
3540 KB |
Output is correct |
9 |
Correct |
15 ms |
3540 KB |
Output is correct |
10 |
Correct |
12 ms |
3164 KB |
Output is correct |
11 |
Correct |
16 ms |
3152 KB |
Output is correct |
12 |
Correct |
14 ms |
2892 KB |
Output is correct |
13 |
Correct |
15 ms |
2872 KB |
Output is correct |
14 |
Correct |
11 ms |
2996 KB |
Output is correct |
15 |
Correct |
14 ms |
3016 KB |
Output is correct |
16 |
Correct |
15 ms |
2980 KB |
Output is correct |
17 |
Correct |
13 ms |
3164 KB |
Output is correct |
18 |
Correct |
12 ms |
3164 KB |
Output is correct |
19 |
Correct |
13 ms |
3160 KB |
Output is correct |
20 |
Correct |
10 ms |
3676 KB |
Output is correct |
21 |
Correct |
12 ms |
3624 KB |
Output is correct |
22 |
Correct |
16 ms |
3432 KB |
Output is correct |
23 |
Correct |
14 ms |
3572 KB |
Output is correct |
24 |
Correct |
14 ms |
3356 KB |
Output is correct |
25 |
Correct |
14 ms |
3412 KB |
Output is correct |
26 |
Correct |
14 ms |
3516 KB |
Output is correct |
27 |
Correct |
13 ms |
3536 KB |
Output is correct |
28 |
Correct |
18 ms |
3472 KB |
Output is correct |
29 |
Correct |
11 ms |
3392 KB |
Output is correct |
30 |
Correct |
15 ms |
3376 KB |
Output is correct |
31 |
Correct |
2 ms |
1172 KB |
Output is correct |
32 |
Correct |
1 ms |
1172 KB |
Output is correct |
33 |
Correct |
2 ms |
1168 KB |
Output is correct |
34 |
Correct |
1 ms |
1040 KB |
Output is correct |
35 |
Correct |
1 ms |
1036 KB |
Output is correct |
36 |
Correct |
2 ms |
1036 KB |
Output is correct |
37 |
Correct |
2 ms |
1036 KB |
Output is correct |
38 |
Correct |
1 ms |
1044 KB |
Output is correct |
39 |
Correct |
1 ms |
1036 KB |
Output is correct |
40 |
Correct |
2 ms |
1036 KB |
Output is correct |
41 |
Correct |
2 ms |
1036 KB |
Output is correct |
42 |
Correct |
2 ms |
1036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1048 KB |
Output is correct |
2 |
Correct |
2 ms |
1044 KB |
Output is correct |
3 |
Correct |
2 ms |
1040 KB |
Output is correct |
4 |
Correct |
2 ms |
1572 KB |
Output is correct |
5 |
Correct |
2 ms |
1588 KB |
Output is correct |
6 |
Correct |
2 ms |
1600 KB |
Output is correct |
7 |
Correct |
2 ms |
1576 KB |
Output is correct |
8 |
Correct |
3 ms |
1584 KB |
Output is correct |
9 |
Correct |
11 ms |
4180 KB |
Output is correct |
10 |
Correct |
11 ms |
4164 KB |
Output is correct |
11 |
Correct |
12 ms |
4196 KB |
Output is correct |
12 |
Correct |
2 ms |
1036 KB |
Output is correct |
13 |
Correct |
2 ms |
1132 KB |
Output is correct |
14 |
Correct |
1 ms |
1036 KB |
Output is correct |
15 |
Correct |
2 ms |
1040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
3652 KB |
Output is correct |
2 |
Correct |
19 ms |
3660 KB |
Output is correct |
3 |
Correct |
24 ms |
3640 KB |
Output is correct |
4 |
Correct |
16 ms |
3144 KB |
Output is correct |
5 |
Partially correct |
15 ms |
3928 KB |
Partially correct |
6 |
Correct |
14 ms |
3540 KB |
Output is correct |
7 |
Correct |
13 ms |
3536 KB |
Output is correct |
8 |
Correct |
13 ms |
3408 KB |
Output is correct |
9 |
Correct |
13 ms |
3420 KB |
Output is correct |
10 |
Correct |
11 ms |
3160 KB |
Output is correct |
11 |
Correct |
16 ms |
3108 KB |
Output is correct |
12 |
Correct |
15 ms |
2860 KB |
Output is correct |
13 |
Correct |
12 ms |
2892 KB |
Output is correct |
14 |
Correct |
13 ms |
2948 KB |
Output is correct |
15 |
Correct |
13 ms |
3024 KB |
Output is correct |
16 |
Correct |
13 ms |
3164 KB |
Output is correct |
17 |
Correct |
13 ms |
3024 KB |
Output is correct |
18 |
Correct |
13 ms |
3060 KB |
Output is correct |
19 |
Correct |
14 ms |
3100 KB |
Output is correct |
20 |
Incorrect |
14 ms |
3704 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
3644 KB |
Output is correct |
2 |
Correct |
24 ms |
3688 KB |
Output is correct |
3 |
Correct |
19 ms |
3992 KB |
Output is correct |
4 |
Correct |
13 ms |
3352 KB |
Output is correct |
5 |
Correct |
14 ms |
4232 KB |
Output is correct |
6 |
Correct |
14 ms |
3612 KB |
Output is correct |
7 |
Correct |
16 ms |
3552 KB |
Output is correct |
8 |
Correct |
14 ms |
3704 KB |
Output is correct |
9 |
Correct |
13 ms |
3612 KB |
Output is correct |
10 |
Correct |
12 ms |
3380 KB |
Output is correct |
11 |
Correct |
13 ms |
3380 KB |
Output is correct |
12 |
Correct |
13 ms |
3104 KB |
Output is correct |
13 |
Correct |
13 ms |
3096 KB |
Output is correct |
14 |
Correct |
13 ms |
3088 KB |
Output is correct |
15 |
Correct |
13 ms |
3244 KB |
Output is correct |
16 |
Correct |
13 ms |
3248 KB |
Output is correct |
17 |
Correct |
14 ms |
3332 KB |
Output is correct |
18 |
Correct |
14 ms |
3328 KB |
Output is correct |
19 |
Correct |
14 ms |
3364 KB |
Output is correct |
20 |
Incorrect |
11 ms |
3860 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |