Submission #951176

#TimeUsernameProblemLanguageResultExecution timeMemory
951176glebustimTriangles (CEOI18_tri)C++17
20 / 100
1 ms600 KiB
#include "trilib.h" //#include "trilib.c" #include <bits/extc++.h> using namespace std; using namespace __gnu_pbds; #define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define all(a) a.begin(), a.end() using ll = long long; using ld = long double; using pii = pair<int, int>; using vi = vector<int>; using oset = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>; bool is_inside(int a, int b, int c, int d) { bool x = is_clockwise(a, b, d), y = is_clockwise(b, c, d), z = is_clockwise(c, a, d); return (x == y && y == z); } int O; bool comp(int x, int y) { return is_clockwise(O, y, x); } int main() { int n = get_n(), a = 1, b = 2, c = 3; for (int i = 4; i <= n; ++i) { if (!is_clockwise(a, b, c)) swap(b, c); if (is_clockwise(a, b, i)) { if (is_inside(a, b, i, c)) c = i; } else if (is_clockwise(b, c, i)) { if (is_inside(b, c, i, a)) a = i; } else if (is_inside(a, c, i, b)) b = i; } O = a; vi p(n - 1); for (int i = 1; i < O; ++i) p[i - 1] = i; for (int i = O + 1; i <= n; ++i) p[i - 2] = i; sort(all(p), comp); vi st; st.push_back(O); for (int i: p) { while (st.size() > 1 && is_clockwise(st[(int)st.size() - 2], st.back(), i)) st.pop_back(); st.push_back(i); } give_answer((int)st.size()); }
#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...