# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1060131 | Szymon_Pilipczuk | Triangles (CEOI18_tri) | C++17 | 1 ms | 420 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 "trilib.h"
//#include <iostream>
using namespace std;
/*int get_n()
{
int n;
cin>>n;
return n;
}
bool is_clockwise(int a,int b,int c)
{
cout<<a<<" "<<b<<" "<<c<<"\n";
int result;
cin>>result;
if(result ==0)
{
return false;
}
else
{
return true;
}
}
void give_answer(int s)
{
cout<<s<<"\n";
}*/
int main()
{
int n = get_n();
int p[n];
p[0] = 1;
if(is_clockwise(1,2,3))
{
p[1] = 2;
p[2] = 3;
}
else
{
p[1] = 3;
p[2] = 2;
}
int ans = 3;
int l,r;
for(int i =4;i<=n;i++)
{
l = 0;
r = ans -1 ;
int mr = ans;
while(r>(l+2)%ans)
{
if(r == ans-1 && l == 0)
{
r = 0;
}
int mid = (mr+l+1)/2;
// cout<<mid;
if(is_clockwise(p[l],p[mid],i))
{
l = mid;
}
else
{
r = mid;
mr = mid;
}
}
bool ans2 = is_clockwise(p[l],p[l+1],i);
bool ans3 = is_clockwise(p[l+1],p[r],i);
// cout<<ans<<"\n";
if(ans == 3)
{
if (ans2 == false &&ans3 == false)
{
p[l+1] = i;
}
else if (ans2&&ans3)
{
p[r+1] = i;
ans++;
}
else
{
bool ans4 = is_clockwise(p[l],p[r],i);
if(ans4)
{
if(ans2)
{
p[r] = i;
}
else
{
p[l] = i;
}
}
else
{
if(ans2)
{
int cu = i;
int cu2;
for(int j = r;j<=ans;j++)
{
cu2 = cu;
cu = p[j];
p[j] = cu2;
}
ans++;
}
else
{
int cu = i;
int cu2;
for(int j = l+1;j<=ans;j++)
{
cu2 = cu;
cu = p[j];
p[j] = cu2;
}
ans++;
}
}
}
}
else
{
if(ans2 ==false)
{
if(ans3 == false)
{
p[l+1] = i;
}
else
{
int cu = i;
int cu2;
for(int j = l+1;j<=ans;j++)
{
cu2 = cu;
cu = p[j];
p[j] = cu2;
}
ans++;
}
}
else if(ans3 == false)
{
int cu = i;
int cu2;
for(int j = r;j<=ans;j++)
{
cu2 = cu;
cu = p[j];
p[j] = cu2;
}
ans++;
}
}
}
give_answer(ans);
}
# | 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... |