#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
/*bool query(int a,int b,int c,int d)
{
printf("%i-%i %i-%i?\n",a,b,c,d);
int res;
scanf("%i",&res);
return res;
}*/
int query(int a,int b,int c,int d);
bool levo(int poz)
{
return query(poz,poz,poz,poz-1);
}
bool desno(int poz)
{
return query(poz,poz,poz,poz+1);
}
int n;
bool inside(int poz)
{
return poz>=0&&poz<n;
}
int solve(int _N,int* Left,int* Right)
{
n=_N;
fill(Left,Left+n,-1);
fill(Right,Right+n,-1);
vector<int> parent(n);
fill(parent.begin(),parent.end(),-1);
for(int i=0;i<n;i++)
{
if(inside(i-1)&&parent[i]==-1)
{
if(levo(i))
{
int tr=i-1;
while(parent[tr]!=-1)
tr=parent[tr];
int l=tr,r=i-1;
while(l<r)
{
int m=(l+r)>>1;
if(query(i,i,m,i))
{
r=m;
}
else
{
l=m+1;
}
}
parent[i]=parent[l];
Right[parent[i]]=i;
Left[i]=l;
parent[l]=i;
}
else
assert(0);
}
if(inside(i+1))
{
if(desno(i))
{
assert(parent[i+1]==-1);
parent[i+1]=i;
Right[i]=i+1;
}
}
/* printf("Left:\n");
for(int i=0;i<n;i++)
{
printf("%i ",Left[i]);
}
printf("\nRight:\n");
for(int i=0;i<n;i++)
{
printf("%i ",Right[i]);
}
printf("\n");*/
}
/*printf("Left:\n");
for(int i=0;i<n;i++)
{
printf("%i ",Left[i]);
}
printf("\nRight:\n");
for(int i=0;i<n;i++)
{
printf("%i ",Right[i]);
}*/
}
int main()
{
int n;
scanf("%i",&n);
int *L=new int[n];
int *R=new int[n];
solve(n,L,R);
return 0;
}
Compilation message
popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:96:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
popa.cpp: In function 'int main()':
popa.cpp:100:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i",&n);
~~~~~^~~~~~~~~
/tmp/ccce5OvQ.o: In function `main':
popa.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc5CUkpM.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status