Submission #898249

#TimeUsernameProblemLanguageResultExecution timeMemory
898249math_rabbit_1028Triangles (CEOI18_tri)C++14
20 / 100
1 ms500 KiB
#include <bits/stdc++.h> #include "trilib.h" using namespace std; int n, origin; vector<int> up, dn; bool compare(int i, int j) { return is_clockwise(i, 1, j); } bool compare2(int i, int j) { return !is_clockwise(i, 1, j); } 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(), compare); sort(dn.begin(), dn.end(), compare2); 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); } int v = dq.back(); dq.pop_back(); reverse(dq.begin(), dq.end()); 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); give_answer(dq.size()); } int main() { solve(); }

Compilation message (stderr)

tri.cpp: In function 'void solve()':
tri.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (int i = 0; i < up.size(); i++) {
      |                     ~~^~~~~~~~~~~
tri.cpp:44:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     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...