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];
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) == 0){
if (ans1 == 0 && ans2 == 0)
solve(l,mid);
if (ans1 == 0 && ans2 == 0)
solve(mid+1,r);
}
else
{
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]]=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]]=i;
pt[3]++;
}
c[0]=ans1;
if (query(1,pt[3],c,d) == 0)
nowl=nowmid+1;
else
nowr=nowmid;
}
ans2=a[nowl];
}
}
}
void run(int N){
for (int i=1;i<N;i++){
ans1=0; ans2=0;
solve(1,N);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |