Submission #481203

#TimeUsernameProblemLanguageResultExecution timeMemory
481203hidden1Triangles (CEOI18_tri)C++14
100 / 100
25 ms2956 KiB
#include <bits/stdc++.h> #include "trilib.h" using namespace std; //#pragma GCC optimize ("O3") //#pragma GCC target ("sse4") #ifndef LOCAL #define cerr if(false) cerr #endif #define endl "\n" #define all(x) (x).begin(), (x).end() #define forn(i, n) for(int i = 0; i < n; i ++) #define revn(i, n) for(int i = n - 1; i >= 0; i --) typedef long long ll; template<class T, template<class T2, class A=allocator<T2> > class cont> inline ostream &operator <<(ostream &out, const cont<T> &x) { for(const auto &it : x) { out << it << " ";} return out;} template<class T, template<class T2, class A=allocator<T2> > class cont> inline istream &operator >>(istream &in, cont<T> &x) { for(auto &it : x) { in >> it;} return in;} template<class T, class T2> inline ostream &operator <<(ostream &out, const pair<T, T2> &x) { out << x.first << " " << x.second; return out;} template<class T, class T2> inline istream &operator >>(istream &in, pair<T, T2> &x) { in >> x.first >> x.second; return in;} template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; } template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; } const ll mod = 1e9 + 7; signed main() { // ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; int special = 1; n = get_n(); vector<int> vert1, vert2; forn(i, n) { if(i != 0 && i != 1) { if(is_clockwise(1, 2, i + 1)) { vert1.push_back(i + 1); } else { vert2.push_back(i + 1); } } } sort(all(vert1), [&special](const int a, const int b) { return (bool)!is_clockwise(1, a, b); }); sort(all(vert2), [&special](const int a, const int b) { return (bool)!is_clockwise(1, a, b); }); vector<int> vert; vert.push_back(1); for(auto it : vert1) {vert.push_back(it);} vert.push_back(2); for(auto it : vert2) {vert.push_back(it);} vector<int> st; for(auto it : vert) { while(!(st.size() < 2) && is_clockwise(st[st.size() - 2], st[st.size() - 1], it)) { st.pop_back(); } st.push_back(it); } int ret = st.size(); auto cpy = st; for(auto it : cpy) { while(!(st.size() < 2) && is_clockwise(st[st.size() - 2], st[st.size() - 1], it)) { st.pop_back(); ret --; } st.push_back(it); } give_answer(ret); return 0; }
#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...