Submission #115917

#TimeUsernameProblemLanguageResultExecution timeMemory
115917MeloricTriangles (CEOI18_tri)C++14
0 / 100
3 ms640 KiB
#include "trilib.h" #include <bits/stdc++.h> //#define int int64_t #define pb push_back #define X first #define Y second #define pii pair<int, int> using namespace std; /* int get_n(){ int c; cin >> c; return c; } void give_answer(int a){ cout << a; } bool is_clockwise(int a, int b, int c){ cout << a << ' '<<b <<' '<<c<<endl; bool d; cin >> d; return d; } */ bool ask(int a, int b, int c){ a++; b++; c++; return is_clockwise(a, b, c); } void quick(int l, int r, vector<int>&srt){ if(r-l<2)return; vector<int> sml, big; int piv = srt[l]; for(int i = l+1; i<r; i++){ int cur = srt[i]; if(ask(srt[0], piv, cur))sml.pb(cur); else big.pb(cur); } int counter = l; for(int i = 0; i < sml.size(); i++){ srt[l+i] = sml[i]; counter++; } srt[counter] = piv; counter++; for(int i = 0; i < big.size(); i++){ srt[i+counter]=big[i]; } /* for(auto i : srt)cout << i+1 <<' '; cout << endl; */ quick(l, counter-1, srt); quick(counter, r, srt); } signed main(){ ios_base::sync_with_stdio(false); //cin.tie(0); int n; n = get_n(); if(n==3)give_answer(3); assert(false); vector<int> srt(n); iota(srt.begin(), srt.end(), 0); srand(41); random_shuffle(srt.begin(), srt.end()); quick(1, n, srt); //for(auto i : srt)cout << i+1 <<' '; for(int i = 0; i< n; i++)srt.pb(srt[i]); vector<int> hull; /* for(auto i : srt)cout << i+1 <<' '; cout << endl; */ for(int i = 0; i< srt.size(); i++){ int sz = hull.size(); while(sz>1 && ask(hull[sz-2], hull[sz-1], srt[i])){ hull.pop_back(); sz--; } hull.pb(srt[i]); } vector<int> tmp(n); for(auto i : hull)tmp[i]++; int ans = 0; for(auto i : tmp){ if(i == 2)ans++; } give_answer(ans); return 0; }

Compilation message (stderr)

tri.cpp: In function 'void quick(int, int, std::vector<int>&)':
tri.cpp:38:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < sml.size(); i++){
                    ~~^~~~~~~~~~~~
tri.cpp:44:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < big.size(); i++){
                    ~~^~~~~~~~~~~~
tri.cpp: In function 'int main()':
tri.cpp:72:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i< srt.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...