# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
700122 | urosk | Airline Route Map (JOI18_airline) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Alicelib.h"
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include "bits/stdc++.h"
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ld double
#define ll int
#define llinf 100000000000000000LL // 10^17
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) (ll)(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}
#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
using namespace std;
#define maxn 2020
void Alice(ll N,ll M,ll A[],ll B[] ){
ll n = N,m = M;
ll d = 12;
ll v = n+d,u = m;
vector<pll> a;
vector<ll> want(maxn,0);
vector<ll> deg(maxn,0);
vector<vector<bool> > ima(maxn,vector<bool>(maxn,0));
for(ll i = 0;i<m;i++) a.pb({A[i],B[i]});
for(ll i = 0;i<v-2;i++) a.pb({i,v-1});
for(ll i = n;i<v-2;i++) a.pb({i,v-2});
a.pb({v,n});
set<pll> s;
for(ll i = n;i<v-2;i++) want[i] = i-n;
for(ll i = 0;i<v;i++) ima[i][i] = 1;
for(ll i = v-3;i>n;i--){
if(want[i]){
a.pb({i,n});
deg[i]++;
deg[n]++;
want[i]--;
}
ll j = i-1;
while(want[i]&&j>=n){
if(want[j]&&!ima[i][j]){
ima[i][j] = ima[j][i] = 1;
a.pb({i,j});
want[j]--;
want[i]--;
deg[i]++;
deg[j]++;
}
j--;
}
}
//ceri(deg,n,v-3);
for(ll i = 0;i<n;i++){
for(ll j = 0;j<d-2;j++){
if((1<<j)&i) a.pb({i,n+j});
}
}
u = sz(a);
InitG(v+1,u);
//dbg(sz(a));
//for(pll p : a) cerr<<p.fi<< " "<<p.sc<<endl;
for(ll i = 0;i<u;i++) MakeG(i,a[i].fi,a[i].sc);
}
/**
4 3
0 1
0 2
0 3
**/