# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
316554 | bigg | 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 "Boblib.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
static vector<int> vgrafo[1505], auxbin[1505];
static vector<pair<int, int> > grafo;
static int marc1[1505][1505];
static int marc[1505], whichbin[1505], whichr[1505];
static std::vector<int> bin;
void Bob( int V, int U, int C[], int D[] ){
int aux1, aux2, auxaux1 = 0;
for(int i = 0; i < U; i++){
//printf("%d %d\n",C[i], D[i] );
vgrafo[C[i]].push_back(D[i]);
vgrafo[D[i]].push_back(C[i]);
if(vgrafo[D[i]].size() > auxaux1){
aux1 = D[i];
auxaux1 = vgrafo[D[i]].size();
}
if(vgrafo[C[i]].size() > auxaux1){
aux1 = C[i];
auxaux1 = vgrafo[C[i]].size();
}
}
int n = V - 12;
for(int i = 0; i < V; i++){
if(i == aux1) continue;
bool ok = 1;
for(auto u : vgrafo[i]){
if(u == aux1) ok = 0;
}
if(ok){
aux2 = i;
break;
}
}
//printf("%d %d\n", aux1, aux2);
for(auto u : vgrafo[aux2]){
marc[u] = 1;
}
int b0;
for(auto u : vgrafo[aux2]){
for(auto v : vgrafo[u]){
if(!marc[v]) continue;
auxbin[u].push_back(v);
}
if(auxbin[u].size() == 1) b0 = u;
}
//printf("Chegueiaqui!\n");
int r0 = b0;
for(int i = 0; i < 10; i++){
bin.push_back(b0);
whichbin[b0] = i;
if(i == 0) b0 = auxbin[b0][0];
else if(i == 1){
for(auto u : auxbin[b0]){
if(whichbin[u] == r0) continue;
if(auxbin[u].size() > 2) continue;
b0 = u;
break;
}
}else if(i == 3){
for(auto u : auxbin[b0]){
if(whichbin[u] == i - 1) continue;
if(auxbin[u].size() > 2) continue;
b0 = u;
break;
}
}else{
for(auto u : auxbin[b0]){
if(whichbin[u] == i - 1) continue;
b0 = u;
break;
}
}
}
for(int i = 0; i < 10; i++){
int x = bin[i];
for(auto u : vgrafo[x]){
if(auxbin[u].size() > 0 )continue;
if(u == aux1) continue;
if(u == aux2) continue;
whichr[u] |= (1<<i);
//printf("%d %d\n",i, whichr[u] );
}
}
for(int i = 0; i < V; i++){
if(i == aux1 || i == aux2) continue;
if(auxbin[i].size() > 0) continue;
for(auto u : vgrafo[i]){
if( u == aux1 || u == aux2 ) continue;
if(auxbin[u].size() > 0) continue;
if(!marc1[i][u]){
grafo.push_back(make_pair(whichr[i], whichr[u]));
}
marc1[i][u] = 1;
marc1[u][i] = 1;
}
}
InitMap(n, grafo.size());
for(int i = 0; i < grafo.size(); i++){
MakeMap(grafo[i].first, grafo[i].second);
}
}