# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
388896 | mariowong | ICC (CEOI16_icc) | 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 <bits/stdc++.h>
#include "icc.h"
using namespace std;
/*
int a[105],b[105],pt[10],ans1,ans2,nowl,nowr,nowmid,c[105],d[105],x;
int query (int sz1,int sz2,int e[],int g[]){
for (int i=0;i<sz1;i++){
cout << e[i] << " ";
}
cout << "\n";
for (int i=0;i<sz2;i++){
cout << g[i] << " ";
}
cout << "\n";
cin >> x;
return x;
}
void setRoad(int a1,int a2){
cout << "Road set: " << a1 << " " << a2 << "\n";
}*/
void solve(int l,int r){
int mid=(l+r)/2;
if (l == r);
else
{
pt[0]=0; pt[1]=0;
for (int i=l;i<=mid;i++){
a[pt[0]]=i;
pt[0]++;
}
for (int i=mid+1;i<=r;i++){
b[pt[1]]=i;
pt[1]++;
}
if (query(pt[0],pt[1],a,b) == 1){
nowl=0; nowr=pt[0]-1;
while (nowl < nowr){
nowmid=(nowl+nowr)/2; pt[2]=0;
for (int i=nowl;i<=nowmid;i++){
c[pt[2]]=a[i];
pt[2]++;
}
if (query(pt[2],pt[1],c,b) == 0)
nowl=nowmid+1;
else
nowr=nowmid;
}
ans1=a[nowl];
nowl=0; nowr=pt[1]-1;
while (nowl < nowr){
nowmid=(nowl+nowr)/2; pt[3]=0;
for (int i=nowl;i<=nowmid;i++){
d[pt[3]]=b[i];
pt[3]++;
}
c[0]=ans1;
if (query(1,pt[3],c,d) == 0)
nowl=nowmid+1;
else
nowr=nowmid;
}
ans2=b[nowl];
}
else
if (query(pt[1],pt[0],b,a) == 1){
swap(a,b); swap(pt[0],pt[1]);
nowl=0; nowr=pt[0]-1;
while (nowl < nowr){
nowmid=(nowl+nowr)/2; pt[2]=0;
for (int i=nowl;i<=nowmid;i++){
c[pt[2]]=a[i];
pt[2]++;
}
if (query(pt[2],pt[1],c,b) == 0)
nowl=nowmid+1;
else
nowr=nowmid;
}
ans1=a[nowl];
nowl=0; nowr=pt[1]-1;
while (nowl < nowr){
nowmid=(nowl+nowr)/2; pt[3]=0;
for (int i=nowl;i<=nowmid;i++){
d[pt[3]]=b[i];
pt[3]++;
}
c[0]=ans1;
if (query(1,pt[3],c,d) == 0)
nowl=nowmid+1;
else
nowr=nowmid;
}
ans2=b[nowl];
}
else
{
if (ans1 == 0 && ans2 == 0)
solve(l,mid);
if (ans1 == 0 && ans2 == 0)
solve(mid+1,r);
}
}
}
void run(int N){
for (int i=1;i<N;i++){
ans1=0; ans2=0;
solve(1,N);
setRoad(ans1,ans2);
}
}
/*int main(){
run(4);
}*/