# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
991852 | simona1230 | Airline Route Map (JOI18_airline) | C++17 | 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 <bits/stdc++.h>
#include "Alicelib.h"
using namespace std;
void Alice(int n,int m,int a[],int b[])
{
vector<pair<int,int> > v;
int l[1024];
int num=0;
for(int i=0;i<n;i++)
{
int cnt=i+3;
l[i]=num;
for(int j=1;j<cnt;j++)
{
v.push_back({num,num+1});
num++;
}
v.push_back({num,num-cnt+1});
num++;
v.push_back({l[i],num});
l[i]=num;
}
for(int i=0;i<m;i++)
{
v.push_back({l[a[i]],l[b[i]]});
}
InitG(num,v.size());
for(int i=0;i<v.size();i++)
{
MakeG(i,v[i].first,v[i].second);
}
}
#include <bits/stdc++.h>
#include "Boblib.h"
using namespace std;
int x[100001],y[100001];
vector<int> e[100001];
int used[100001];
int l[100001];
int maxx=0;
void dfs(int i,int c,int bg,int p)
{
used[i]=1;
for(int j=0;j<e[i].size();j++)
{
int nb=e[i][j];
if(e[nb].size()==2&&nb!=p)dfs(nb,c+1,bg,i);
else
{
maxx=max(maxx,c-2);
for(int k=0;k<e[bg].size();k++)
{
if(!used[e[bg][i]])
l[e[nb][i]]=c-2;
}
}
}
}
void Bob(int v,int u,int c[],int d[])
{
for(int i=0;i<u;i++)
{
e[c[i]].push_back(d[i]);
e[d[i]].push_back(c[i]);
}
for(int i=0;i<v;i++)
{
if(e[i].size()==3)dfs(i,1,i,-1);
}
for(int i=0;i<u;i++)
{
if(l[c[i]]&&l[d[i]])
ans.push_back({l[c[i]]-1,l[d[i]]-1});
}
InitMap(maxx,ans.size());
for(int i=0;i<ans.size();i++)
MakeMap(ans[i].first,ans[i].second);
}