Submission #954947

#TimeUsernameProblemLanguageResultExecution timeMemory
954947hyakupTriangles (CEOI18_tri)C++17
100 / 100
28 ms2872 KiB
#include <bits/stdc++.h> #include "trilib.h" #include <random> using namespace std; 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, marc(n + 1, -1); for( int i = 1; i <= n; i++ ) v.push_back(i); shuffle( v.begin(), v.end(), rng ); resp.push_back(v[0]); ordena(v, resp); for( int i = 0; i < n; i++ ) resp.push_back(resp[i]); vector<int> hull; 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( marc[hull[i]] == -1 ){ marc[hull[i]] = i; continue; } give_answer(i - marc[hull[i]]); break; } }

Compilation message (stderr)

tri.cpp: In function 'void ordena(std::vector<int>&, std::vector<int>&)':
tri.cpp:10:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |   for( int i = 2; i < v.size(); i++ ){
      |                   ~~^~~~~~~~~~
tri.cpp: In function 'int main()':
tri.cpp:32:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for( int i = 0; i < hull.size() - 1; 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...