이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include"trilib.h"
using namespace std;
int root;
bool cmp(int x, int y){
return is_clockwise(root, x, y);
}
vector<int> getstv(vector<int> v, int st, int en){
root = st;
sort(v.begin(), v.end(), cmp);
vector<int> stv;
stv.push_back(st);
for(auto x: v){
while(stv.size() > 1 && is_clockwise(stv.end()[-2], stv.end()[-1], x) == false)
stv.pop_back();
stv.push_back(x);
}
return stv;
}
int main(){
int n = get_n();
int a = 1;
int b = 2;
vector<int> l, r;
for(int i = 3; i<= n; i++){
if(is_clockwise(a, b, i) == false)
l.push_back(i);
else
r.push_back(i);
}
///L ARE ORDINEA DE LA A LA B, R DE LA B LA A
vector<int> stvl = getstv(l, a, b);
vector<int> stvr = getstv(r, b, a);
if(l.size() == 0){
give_answer(stvr.size());
return 0 ;
}
if(r.size() == 0){
give_answer(stvl.size());
return 0 ;
}
int fixed;
vector<int> cstvl = stvl;
for(auto x: stvr){
while(cstvl.size() > 1 && (x == cstvl.end()[-1] || is_clockwise(cstvl.end()[-2], cstvl.end()[-1], x) == false))
cstvl.pop_back();
}
fixed = cstvl.back();
int poz = cstvl.size();
vector<int> stv;
stv.push_back(fixed);
for(int i = poz; i < stvl.size(); i++){
int x = stvl[i];
while(stv.size() > 1 && (x == stv.end()[-1] || is_clockwise(stv.end()[-2], stv.end()[-1], x) == false))
stv.pop_back();
stv.push_back(x);
}
for(auto x: stvr){
while(stv.size() > 1 && (x == stv.end()[-1] || is_clockwise(stv.end()[-2], stv.end()[-1], x) == false))
stv.pop_back();
stv.push_back(x);
}
for(int i = 0; i < poz - 1; i++){
int x = stvl[i];
while(stv.size() > 1 && (x == stv.end()[-1] || is_clockwise(stv.end()[-2], stv.end()[-1], x) == false))
stv.pop_back();
stv.push_back(x);
}
give_answer(stv.size());
}
컴파일 시 표준 에러 (stderr) 메시지
tri.cpp: In function 'int main()':
tri.cpp:54:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for(int i = poz; i < stvl.size(); i++){
| ~~^~~~~~~~~~~~~
# | 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... |