#include "Alicelib.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define rep(i, b) for(int i = 0; i < (b); ++i)
#define rep2(i,a,b) for(int i = a; i <= (b); ++i)
#define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c)
#define count_bits(x) __builtin_popcountll((x))
#define all(x) (x).begin(),(x).end()
#define siz(x) (int)(x).size()
#define forall(it,x) for(auto& it:(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//mt19937 mt;void random_start(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());}
//ll los(ll a, ll b) {return a + (mt() % (b-a+1));}
const int INF = 1e9+50;
const ll INF_L = 1e18+40;
const ll MOD = 1e9+7;
void Alice(int n, int m, int A[], int B[])
{
if(n == 1)
{
InitG(1,0);
return;
}
if(n == 2)
{
InitG(2,m);
if(m == 1) MakeG(0,0,1);
return;
}
vector<pii> edges;
rep(i,m)
{
edges.pb({A[i],B[i]});
}
rep2(i,n+1,n+9)
{
edges.pb({i-1,i});
}
edges.pb({n+9,n+7});
edges.pb({n+9,n+6});
rep(i,n)
{
rep(bit,10)
{
if((i+1) & (1 << bit))
{
edges.pb({i,bit+n});
}
}
}
rep(i,n)
{
edges.pb({i,n+10});
}
edges.pb({n+10,n+11});
InitG(n+12,siz(edges));
rep(i,siz(edges))
{
MakeG(i,edges[i].ff,edges[i].ss);
}
}
#include "Boblib.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define rep(i, b) for(int i = 0; i < (b); ++i)
#define rep2(i,a,b) for(int i = a; i <= (b); ++i)
#define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c)
#define count_bits(x) __builtin_popcountll((x))
#define all(x) (x).begin(),(x).end()
#define siz(x) (int)(x).size()
#define forall(it,x) for(auto& it:(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//mt19937 mt;noid random_start(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());}
//ll los(ll a, ll b) {return a + (mt() % (b-a+1));}
const int INF = 1e9+50;
const ll INF_L = 1e18+40;
const ll MOD = 1e9+7;
vi graph[1015];
bool odw[1015];
int bit[1015];
int rel_num[1015];
void Bob(int n, int U, int C[], int D[])
{
if(n == 1)
{
InitMap(1,0);
return;
}
if(n == 2)
{
InitMap(2,U);
if(U == 1) MakeMap(1,2);
return;
}
int pom;
rep(i,U)
{
graph[C[i]].pb(D[i]);
graph[D[i]].pb(C[i]);
}
rep(i,n)
{
if(siz(graph[i]) == 1) pom = i;
}
int pom2 = graph[pom][0];
rep(i,n) odw[i] = 1;
odw[pom] = 0;
odw[pom2] = 0;
forall(it,graph[pom2])
{
odw[it] = 0;
}
int bit_9 = 0;
int bit_0 = 0;
rep(i,n) if(odw[i])
{
int cnt = 0;
forall(it,graph[i])
{
if(odw[it]) cnt++;
}
if(cnt == 3) bit_9 = i;
if(cnt == 1) bit_0 = i;
bit[i] = -1;
}
bit[bit_9] = 9;
int cur_b = 0;
while(true)
{
bit[bit_0] = cur_b++;
int nxt = -1;
forall(it,graph[bit_0])
{
if(odw[it] && bit[it] == -1) nxt = it;
}
bit_0 = nxt;
if(nxt == -1) break;
}
vector<pii> edges;
rep(i,n) if(!odw[i] && i != pom && i != pom2)
{
int num = 0;
forall(it,graph[i])
{
if(odw[it])
{
num += (1 << bit[it]);
}
else if(it != pom && it != pom2 && i < it) edges.pb({i,it});
}
rel_num[i] = num-1;
}
InitMap(n-12,siz(edges));
forall(it,edges)
{
MakeMap(rel_num[it.ff],rel_num[it.ss]);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |