Submission #468143

#TimeUsernameProblemLanguageResultExecution timeMemory
468143ivan_tudorTriangles (CEOI18_tri)C++14
0 / 100
1 ms332 KiB
#include<bits/stdc++.h> #include"trilib.h" using namespace std; int root; bool cmp(int x, int y){ return is_clockwise(root, x, y); } vector<int> getstv(vector<int> v, int st, int en){ root = st; sort(v.begin(), v.end(), cmp); vector<int> stv; stv.push_back(st); for(auto x: v){ while(stv.size() > 1 && is_clockwise(stv.end()[-2], stv.end()[-1], x) == false) stv.pop_back(); stv.push_back(x); } return stv; } int main(){ int n = get_n(); int a = 3; int b = 6; vector<int> l, r; for(int i = 1; i<= n; i++){ if(i == a) continue; if(i == b) continue; if(is_clockwise(a, b, i) == false) l.push_back(i); else r.push_back(i); } ///L ARE ORDINEA DE LA A LA B, R DE LA B LA A vector<int> stvl = getstv(l, a, b); vector<int> stvr = getstv(r, b, a); if(l.size() == 0){ int x = a; while(stvr.size() > 1 && is_clockwise(stvr.end()[-2], stvr.end()[-1], x) == false) stvr.pop_back(); stvr.push_back(x); give_answer(stvr.size()); return 0 ; } if(r.size() == 0){ int x = b; while(stvl.size() > 1 && is_clockwise(stvl.end()[-2], stvl.end()[-1], x) == false) stvl.pop_back(); stvl.push_back(x); give_answer(stvl.size()); return 0 ; } int fixed; if(stvl.size() < stvr.size()) swap(stvl, stvr); vector<int> cstvl = stvl; for(auto x: stvr){ while(cstvl.size() > 1 && (x == cstvl.end()[-1] || is_clockwise(cstvl.end()[-2], cstvl.end()[-1], x) == false)) cstvl.pop_back(); } fixed = cstvl.back(); int poz = cstvl.size(); vector<int> stv; stv.push_back(fixed); for(int i = poz; i < stvl.size(); i++){ int x = stvl[i]; while(stv.size() > 1 && (x == stv.end()[-1] || is_clockwise(stv.end()[-2], stv.end()[-1], x) == false)) stv.pop_back(); stv.push_back(x); } for(auto x: stvr){ while(stv.size() > 1 && (x == stv.end()[-1] || is_clockwise(stv.end()[-2], stv.end()[-1], x) == false)) stv.pop_back(); stv.push_back(x); } for(int i = 0; i < poz - 1; i++){ int x = stvl[i]; while(stv.size() > 1 && (x == stv.end()[-1] || is_clockwise(stv.end()[-2], stv.end()[-1], x) == false)) stv.pop_back(); stv.push_back(x); } give_answer(stv.size()); }

Compilation message (stderr)

tri.cpp: In function 'int main()':
tri.cpp:68:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |   for(int i = poz; i < stvl.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...