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"
#include<bits/stdc++.h>
using namespace std;
void Alice(int N, int M, int A[], int B[])
{
int cnte=M;
for(int i=0;i<N;i++)
for(int b=0;b<10;b++)
if((i&(1<<b)))
cnte++;
for(int i=0;i<N+10;i++)
cnte++;
for(int i=0;i<10;i++)
cnte++;
for(int i=0;i<9;i++)
cnte++;
InitG(N+12, cnte);
int cv=0;
for(int i=0;i<M;i++)
MakeG(cv++,A[i],B[i]);
for(int i=0;i<N;i++)
for(int b=0;b<10;b++)
if((i&(1<<b)))
MakeG(cv++,i,N+b);
for(int i=0;i<N+10;i++)
MakeG(cv++,N+10,i);
for(int i=0;i<10;i++)
MakeG(cv++,N+11,N+i);
for(int i=0;i<9;i++)
MakeG(cv++,N+i,N+i+1);
}
#include "Boblib.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> con[1100];
map<pair<int,int>,int> mp;
int p,q;
int sum[1100];
int b[12];
void Bob(int V, int U, int C[], int D[])
{
for(int i=0;i<U;i++)
{
con[C[i]].push_back(D[i]);
con[D[i]].push_back(C[i]);
}
for(int i=0;i<V;i++)
{
if((int)con[i].size() == V-2)
{
for(auto x:con[i])
{
mp[{i,x}]++;
mp[{x,i}]++;
}
p=i;
for(int j=0;j<V;j++)
if(j!=i && mp[{i,j}]==0)
q=j;
break;
}
}
for(auto x:con[q])
{
for(auto y:con[x])
{
mp[{x,y}]++;
mp[{y,x}]++;
}
}
b[0]=-1;
for(auto x:con[q])
{
int aux=0;
for(auto y:con[q])
if(mp[{x,y}])
aux++;
if(aux==1 && b[0]==-1)
b[0]=x;
else if(aux==1)
b[9]=x;
}
if((int)con[b[0]].size() < (int)con[b[9]].size())
swap(b[0],b[9]);
for(int i=1;i<9;i++)
{
for(auto x:con[q])
{
if((i==1 || x!=b[i-2]) && mp[{x,b[i-1]}])
{
b[i]=x;
break;
}
}
}
for(int i=0;i<10;i++)
for(auto x:con[b[i]])
sum[x] += (1<<i);
vector<pair<int,int>> rez;
for(int i=0;i<V;i++)
{
if(i!=p && i!=q && !mp[{q,i}])
{
//cout<<i<<" "<<sum[i]<<" sum\n";
for(auto x:con[i])
{
if(x!=p && x!=q && !mp[{q,x}])
{
rez.push_back({min(sum[i],sum[x]),max(sum[i],sum[x])});
}
}
}
}
InitMap(V-12,((int)rez.size())/2);
sort(rez.begin(),rez.end());
for(int i=0;i<rez.size();i+=2)
MakeMap(rez[i].first,rez[i].second);
}
Compilation message (stderr)
Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:85:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
85 | for(int i=0;i<rez.size();i+=2)
| ~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |