# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
56272 | Yehezkiel | ICC (CEOI16_icc) | C++11 | 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>
using namespace std;
#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;
int XXn,m,KKK=0;
vector <pii> jawabanGrader;
void run(int a);
void generate(){
int &n=XXn;
srand(time(NULL));
vector <pii> semua;
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
semua.emplace_back(i,j);
random_shuffle(semua.begin(),semua.end());
int par[105];
for(int i=1;i<=n;i++)
par[i]=i;
for(auto isi:semua)
{
int u=isi.fi;int v=isi.se;
while(par[u]!=u)
u=par[u];
while(par[v]!=v)
v=par[v];
if(u==v)
continue;
jawabanGrader.push_back(isi);
par[v]=u;
}
}
int query(int size_a,int size_b,int a[],int b[]){
int &k=KKK;
int &n=XXn;
m--;
if(m<0)
{
cout<<"melebihi M pada penentuan ke "<<k<<endl;
exit(0);
}
bool ada[105];
for(int i=1;i<=n;i++)
ada[i]=false;
for(int i=0;i<size_a;i++)
{
if(ada[a[i]])
{
cout<<"TIDAK DISJOINT"<<endl;
exit(0);
}
ada[a[i]]=true;
}
for(int i=0;i<size_b;i++)
{
if(ada[b[i]])
{
cout<<"TIDAK DISJOINT"<<endl;
exit(0);
}
ada[b[i]]=true;
}
int kiri=0,kanan=0;
for(int i=0;i<size_a;i++)
{
if(a[i]==jawabanGrader[k].fi)
kiri++;
if(a[i]==jawabanGrader[k].se)
kiri++;
}
for(int i=0;i<size_b;i++)
{
if(b[i]==jawabanGrader[k].fi)
kanan++;
if(b[i]==jawabanGrader[k].se)
kanan++;
}
return (kanan==1&&kiri==1)?1:0;
}
void setRoad(int a,int b){
int &k=KKK;
if(k>=jawabanGrader.size())
{
cout<<"OVER TANYA KI"<<endl;
exit(0);
}
//cout<<"dijawab "<<a<<" "<<b<<endl;
//cout<<"harusnya "<<jawabanGrader[k].fi<<" "<<jawabanGrader[k].se<<endl;
if(mp(a,b)!=jawabanGrader[k]&&mp(b,a)!=jawabanGrader[k])
{
cout<<"Salah Jawab"<<endl;
exit(0);
}
//cout<<"sisanya "<<m<<endl;
k++;
}
int main()
{
XXn=100,m=1625;
int n=XXn;
generate();
assert(jawabanGrader.size()==n-1);
run(n);
cout<<"SUKSES"<<endl;
cout<<"Sisa pertanyaan "<<m<<endl;
}