이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "trilib.h"
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
using namespace std;
int N;
vector<int> data, p1, p2;
bool comp(const int &l, const int &r)
{
return !is_clockwise(1, l, r);
}
int main()
{
N = get_n();
for (int i = 3; i <= N; i++)
{
if (is_clockwise(1, i, 2)) {p2.push_back(i);}
else {p1.push_back(i);}
}
sort(p1.begin(), p1.end(), comp);
for (auto &x : p1) {data.push_back(x);}
data.push_back(2);
sort(p2.begin(), p2.end(), comp);
for (auto &x : p2) {data.push_back(x);}
//for (auto &x : data) {cout << x << " ";} cout << "\n";
deque<int> stack;
stack.push_back(1);
for (auto &x : data)
{
while (stack.size() > 1 && is_clockwise(stack[stack.size() - 2], stack.back(), x)) {stack.pop_back();}
stack.push_back(x);
//cout << "inserted " << x << "\n";
}
//for (auto &x : stack) {cout << x << " ";} cout << "\n";
while (stack.size() > 2)
{
if (is_clockwise(stack.front(), stack[1], stack.back())) {stack.pop_front();}
else if (is_clockwise(stack.back(), stack.front(), stack[stack.size() - 2])) {stack.pop_back();}
else {break;}
}
//for (auto &x : stack) {cout << x << " ";} cout << "\n";
give_answer(stack.size());
return 0;
}
# | 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... |