Submission #116020

#TimeUsernameProblemLanguageResultExecution timeMemory
116020MeloricTriangles (CEOI18_tri)C++14
100 / 100
42 ms2744 KiB
#include <bits/stdc++.h>
#include "trilib.h"
#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);
}
bool cmp(int a, int b){
    if(a==b)return 0;
    return !ask(0, a, b);
}
int main(){
    ios_base::sync_with_stdio(false);
    int n; n = get_n();
    //if(n==3)give_answer(3);
    vector<int> up, dw, hull;
    up.pb(1);
    for(int i = 2; i < n; i++){
        if(ask(0, 1, i))up.pb(i);
        else dw.pb(i);
    }
    sort(up.begin(), up.end(), cmp);
    sort(dw.begin(), dw.end(), cmp);
    up.insert(up.begin(), 0);
 
    for(int i = 0; i < dw.size(); i++){
        while(hull.size()>1 && ask(hull.end()[-2], hull.end()[-1], dw[i]))hull.pop_back();
        hull.pb(dw[i]);
    }
    for(int i = 0; i < up.size(); i++){
        while(hull.size()>1 && ask(hull.end()[-2], hull.end()[-1], up[i]))hull.pop_back();
        hull.pb(up[i]);
    }
    int sz = hull.size();
    for(int i = 0; i < dw.size(); i++){
        while(hull.size()>1 && ask(hull.end()[-2], hull.end()[-1], dw[i]))hull.pop_back();
        hull.pb(dw[i]);
    }
    for(int i = 0; i < up.size(); i++){
        while(hull.size()>1 && ask(hull.end()[-2], hull.end()[-1], up[i]))hull.pop_back();
        hull.pb(up[i]);
    }
    give_answer(hull.size()-sz);
    return 0;
}

Compilation message (stderr)

tri.cpp: In function 'int main()':
tri.cpp:45:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < dw.size(); i++){
                    ~~^~~~~~~~~~~
tri.cpp:49:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < up.size(); i++){
                    ~~^~~~~~~~~~~
tri.cpp:54:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < dw.size(); i++){
                    ~~^~~~~~~~~~~
tri.cpp:58:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < up.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...