# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
56272 |
2018-07-11T00:39:40 Z |
Yehezkiel |
ICC (CEOI16_icc) |
C++11 |
|
0 ms |
0 KB |
#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;
}
Compilation message
icc.cpp: In function 'void setRoad(int, int)':
icc.cpp:90:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(k>=jawabanGrader.size())
~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/cassert:44:0,
from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
from icc.cpp:1:
icc.cpp: In function 'int main()':
icc.cpp:110:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
assert(jawabanGrader.size()==n-1);
~~~~~~~~~~~~~~~~~~~~^~~~~
/tmp/cc6Pa9JK.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccJQx46R.o:icc.cpp:(.text.startup+0x0): first defined here
/tmp/ccJQx46R.o: In function `main':
icc.cpp:(.text.startup+0x39): undefined reference to `run(int)'
/tmp/cc6Pa9JK.o: In function `main':
grader.cpp:(.text.startup+0x1d): undefined reference to `run'
collect2: error: ld returned 1 exit status