Submission #954942

#TimeUsernameProblemLanguageResultExecution timeMemory
954942hyakupTriangles (CEOI18_tri)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <random> using namespace std; // int get_n(){ // cout << "N: " << endl; // int x; cin >> x; return x; // } // // bool is_clockwise( int a, int b, int c ){ // cout << a << " " << b << " "<< c << endl; // int x; cin >> x; return x; // } // // void give_answer( int x ){ cout << "RESP: " << x << endl; } void ordena( vector<int>& v, vector<int>& resp ){ if( v.size() == 1 ) return; vector<int> l, r; l.push_back(v[0]); r.push_back(v[0]); for( int i = 2; i < v.size(); i++ ){ if( is_clockwise( v[0], v[1], v[i] ) ) r.push_back(v[i]); else l.push_back(v[i]); } ordena( l, resp ); resp.push_back(v[1]); ordena( r, resp ); } int main(){ mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n = get_n(); vector<int> v, resp; for( int i = 1; i <= n; i++ ) v.push_back(i); shuffle( v.begin(), v.end(), rng ); ordena(v, resp); vector<int> hull; hull.push_back(v[0]); for( int cur : resp ){ while( hull.size() >= 2 && !is_clockwise( hull[hull.size() - 2], hull.back(), cur ) ) hull.pop_back(); hull.push_back(cur); } for( int i = 0; i < hull.size() - 1; i++ ){ if( !is_clockwise(hull[i], hull[i + 1], hull.back()) ) continue; give_answer((int)hull.size() - i); break; } }

Compilation message (stderr)

tri.cpp: In function 'void ordena(std::vector<int>&, std::vector<int>&)':
tri.cpp:21:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   for( int i = 2; i < v.size(); i++ ){
      |                   ~~^~~~~~~~~~
tri.cpp:22:9: error: 'is_clockwise' was not declared in this scope
   22 |     if( is_clockwise( v[0], v[1], v[i] ) ) r.push_back(v[i]);
      |         ^~~~~~~~~~~~
tri.cpp: In function 'int main()':
tri.cpp:30:11: error: 'get_n' was not declared in this scope
   30 |   int n = get_n();
      |           ^~~~~
tri.cpp:37:33: error: 'is_clockwise' was not declared in this scope
   37 |     while( hull.size() >= 2 && !is_clockwise( hull[hull.size() - 2], hull.back(), cur ) ) hull.pop_back();
      |                                 ^~~~~~~~~~~~
tri.cpp:40:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for( int i = 0; i < hull.size() - 1; i++ ){
      |                   ~~^~~~~~~~~~~~~~~~~
tri.cpp:41:10: error: 'is_clockwise' was not declared in this scope
   41 |     if( !is_clockwise(hull[i], hull[i + 1], hull.back()) ) continue;
      |          ^~~~~~~~~~~~
tri.cpp:42:5: error: 'give_answer' was not declared in this scope
   42 |     give_answer((int)hull.size() - i); break;
      |     ^~~~~~~~~~~