Submission #532651

#TimeUsernameProblemLanguageResultExecution timeMemory
532651AugustinasJucasTriangles (CEOI18_tri)C++14
0 / 100
1 ms292 KiB
#include <bits/stdc++.h> #include "trilib.h" using namespace std; int n; int pirmas = 0; /*int get_n(){ return 6; } int queries = 0; vector<int> x(40), y(40); int is_clockwise(int a, int b, int c) { assert(a >= 1 && a <= n); assert(b >= 1 && b <= n); assert(c >= 1 && c <= n); assert(a!=b && a!=c && b!=c); queries++; if(queries == 1000 * 1000 + 1) printf("Too many queries!"); return (x[b]-x[a])*(y[c]-y[a])-(x[c]-x[a])*(y[b]-y[a]) < 0; } */ /* bool is_clockwise (int a, int b, int c) { cout << "ar " << a << " -> " << b << " -> " << c << " pagal? "; bool ans; cin >> ans; return ans; }*/ bool les(int &a, int &b) { // ar a < b if(a == pirmas) return true; if(b == pirmas) return false; return is_clockwise(pirmas, a, b); } vector<int> pasalink(vector<int> mas){ vector<int> ret = {mas[0]}; for(int i = 1; i < mas.size(); i++){ int k = ret.back(); int d = mas[(i+1)%mas.size()]; bool cl = is_clockwise(k, mas[i], d); if(cl){ ret.push_back(mas[i]); } } return ret; } vector<int> hullink(vector<int> &mas) { pirmas = mas[0]; sort(mas.begin(), mas.end(), les); if(mas.size() == 2) { return mas; } return pasalink(mas); } void nuskaityk(){ n = get_n(); /* cin >> n; for(int i = 1; i <= n; i++) { cin >> x[i]; cin >> y[i]; }*/ } int main () { srand(time(0)); nuskaityk(); int A = 1; int B = 2; vector<int> up = {A, B}, down = {A, B}; for(int i = 3; i <= n; i++) { bool cl = is_clockwise(A, B, i); if(cl) up.push_back(i); else down.push_back(i); } auto uphul = hullink(up); auto downhul = hullink(down); if(uphul[1] == B){ swap(uphul, downhul); } vector<int> fin; for(int i = 0; i < uphul.size()-1; i++) { fin.push_back(uphul[i]); } for(int i = 1; i < downhul.size(); i++) { fin.push_back(downhul[i]); } auto finhul = pasalink(fin); give_answer(finhul.size()); /* cout << "jei " << A << "; " << B << " skelia per puse, tai hullai: \n"; cout << "virsuje: "; for(auto x : uphul) cout << x << " "; cout << endl << "apacioje: "; for(auto x : downhul) cout << x << " "; cout << endl << endl; cout << "bendras: "; for(auto x : finhul) { cout << x << " "; } */ return 0; }

Compilation message (stderr)

tri.cpp: In function 'std::vector<int> pasalink(std::vector<int>)':
tri.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i = 1; i < mas.size(); i++){
      |                    ~~^~~~~~~~~~~~
tri.cpp: In function 'int main()':
tri.cpp:86:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |     for(int i = 0; i < uphul.size()-1; i++) {
      |                    ~~^~~~~~~~~~~~~~~~
tri.cpp:89:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |     for(int i = 1; i < downhul.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...