This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |