| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 518890 | ETK | Triangles (CEOI18_tri) | C++14 | 117 ms | 1988 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 "trilib.h"
using namespace std;
#define chk is_clockwise
int main(){
int n = get_n();
vector <int> p;
#define pre(x) ((x + p.size() - 1) % p.size())
#define nxt(x) ((x + 1) % p.size())
if(chk(1,2,3))p = {1,2,3};
else p = {1,3,2};
for(int i = 4;i <= n;i++){
int L = 1,R = p.size() - 2,l = -1;
while(L < R){
int mid = (L + R) >> 1;
if(chk(p[0],p[mid+1],i))L = mid+1;
else R = mid;
}
if(!chk(p[0],p[L],i))l = 0;
else if(!chk(p[L],p[L+1],i))l = L;
else if(!chk(p[L+1],p[0],i))l = L+1;
if(l == -1)continue;//在凸包内
int r = nxt(l);
//找到凸包中前后需要删除的点
while(!chk(p[pre(l)],p[l],i))l = pre(l);
while(!chk(i,p[r],p[nxt(r)]))r = nxt(r);
if(nxt(l) <= r){
if(nxt(l) != r){
int t = nxt(l);
p.erase(p.begin() + nxt(l),p.begin() + r);
r = t;
}
p.insert(p.begin() + r,i);
}else{
p.erase(p.begin() + nxt(l),p.end());
if(r)p.erase(p.begin(),p.begin() + r);
p.push_back(i);
}
}
give_answer(p.size());
}Compilation message (stderr)
| # | 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... | ||||
