제출 #898369

#제출 시각아이디문제언어결과실행 시간메모리
898369math_rabbit_1028Triangles (CEOI18_tri)C++14
20 / 100
1 ms600 KiB
#include <bits/stdc++.h> #include "trilib.h" using namespace std; int n; vector<int> up, dn; void solve() { n = get_n(); for (int i = 3; i <= n; i++) { if (is_clockwise(1, 2, i)) dn.push_back(i); else up.push_back(i); } sort(up.begin(), up.end(), [](int i, int j){ return is_clockwise(i, 1, j); }); sort(dn.begin(), dn.end(), [](int i, int j){ return !is_clockwise(i, 1, j); }); stack<int> stk; deque<int> dq; dq.push_back(1); dq.push_back(2); for (int i = 0; i < up.size(); i++) { int a = dq.back(); dq.pop_back(); while (dq.size() >= 1 && is_clockwise(dq.back(), a, up[i])) { a = dq.back(); dq.pop_back(); } dq.push_back(a); dq.push_back(up[i]); } dq.pop_front(); dq.push_back(1); stk.push(1); stk.push(2); for (int i = 0; i < dn.size(); i++) { int a = stk.top(); stk.pop(); while (stk.size() >= 1 && !is_clockwise(stk.top(), a, dn[i])) { a = stk.top(); stk.pop(); } stk.push(a); stk.push(dn[i]); } while (stk.size() > 2) { int v = stk.top(); stk.pop(); int a = dq.back(); dq.pop_back(); while (dq.size() >= 1 && is_clockwise(dq.back(), a, v)) { a = dq.back(); dq.pop_back(); } dq.push_back(a); dq.push_back(v); } while (dq.size() > 2) { int a = dq.front(); dq.pop_front(); if (is_clockwise(dq.back(), a, dq.front())) continue; dq.push_back(a); a = dq.front(); dq.pop_front(); if (is_clockwise(dq.back(), a, dq.front())) continue; dq.push_front(a); break; } give_answer(dq.size()); } int main() { solve(); }

컴파일 시 표준 에러 (stderr) 메시지

tri.cpp: In function 'void solve()':
tri.cpp:23:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for (int i = 0; i < up.size(); i++) {
      |                     ~~^~~~~~~~~~~
tri.cpp:36:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i = 0; i < dn.size(); i++) {
      |                     ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...