Submission #973794

#TimeUsernameProblemLanguageResultExecution timeMemory
973794efedmrlrTriangles (CEOI18_tri)C++17
0 / 100
1 ms600 KiB
#include <bits/stdc++.h> #include "trilib.h" #define lli long long int #define ld long double #define pb push_back #define MP make_pair #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define REP(i, n) for(int i = 0; (i) < (n); (i)++) using namespace std; void fastio() { ios_base::sync_with_stdio(false); cin.tie(NULL); } int n; void find_hull(vector<int> &p, vector<int> &hull) { if(p.size() < 3) return; int piv = p[0]; p.erase(p.begin()); auto comp = [&piv](int x, int y) { return is_clockwise(piv, x, y); }; sort(all(p), comp); hull.clear(); hull.pb(piv); hull.pb(p[0]); for(int i = 2; i < p.size(); i++) { while(hull.size() > 1 && !is_clockwise(hull[hull.size() - 2], hull.back(), p[i])) { hull.pop_back(); } hull.pb(p[i]); } } void solve() { n = get_n(); vector<int> p; for(int i = 2; i <= n; i++) { p.pb(i); } vector<int> pl = {2, 1}, pr = {1, 2}; for(int i = 3; i <= n; i++) { if(is_clockwise(1, 2, i)) { pl.pb(i); } else { pr.pb(i); } } vector<int> hull1, hull2; find_hull(pl, hull1); find_hull(pr, hull2); vector<int> hull; hull = hull2; for(int i = 1; i < hull1.size(); i++) { while(hull.size() > 1 && !is_clockwise(hull[hull.size() - 2], hull.back(), hull1[i])) { hull.pop_back(); } hull.pb(hull1[i]); } for(int i = 1; i < hull2.size(); i++) { while(hull.size() > 1 && !is_clockwise(hull[hull.size() - 2], hull.back(), hull2[i])) { hull.pop_back(); } hull.pb(hull2[i]); } sort(all(hull)); hull.resize(unique(all(hull)) - hull.begin()); cout << hull.size() << "\n"; } signed main() { solve(); }

Compilation message (stderr)

tri.cpp: In function 'void find_hull(std::vector<int>&, std::vector<int>&)':
tri.cpp:30:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i = 2; i < p.size(); i++) {
      |                    ~~^~~~~~~~~~
tri.cpp: In function 'void solve()':
tri.cpp:59:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(int i = 1; i < hull1.size(); i++) {
      |                    ~~^~~~~~~~~~~~~~
tri.cpp:65:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for(int i = 1; i < hull2.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...