Submission #973799

# Submission time Handle Problem Language Result Execution time Memory
973799 2024-05-02T11:03:36 Z efedmrlr Triangles (CEOI18_tri) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#include "trilib.h"
#define lli long long int
#define ld long double
#define pb push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)

using namespace std;

void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int n;
void find_hull(vector<int> &p, vector<int> &hull) {
    if(p.size() < 3) return;
    int piv = p[0];
    p.erase(p.begin());
    auto comp = [&piv](int x, int y) {
        return is_clockwise(piv, x, y);
    };
    sort(all(p), comp);
    hull.clear();
    hull.pb(piv);
    hull.pb(p[0]);
    for(int i = 2; i < p.size(); i++) {
        while(hull.size() > 1 && !is_clockwise(hull[hull.size() - 2], hull.back(), p[i])) {
            hull.pop_back();
        } 
        hull.pb(p[i]);
    }

}

void solve() {
    n = get_n();
    vector<int> p;
    for(int i = 1; i <= n; i++) {
        p.pb(i);
    }
    vector<int> pl = {2, 1}, pr = {1, 2};
    for(int i = 3; i <= n; i++) {
        if(is_clockwise(1, 2, i)) {
            pl.pb(i);
        }
        else {
            pr.pb(i);
        }
    }
    vector<int> hull1, hull2;
    find_hull(pl, hull1);
    find_hull(pr, hull2);
    vector<int> hull;
    hull = hull2;
    for(int i = 1; i < hull1.size(); i++) {
        while(hull.size() > 1 && !is_clockwise(hull[hull.size() - 2], hull.back(), hull1[i])) {
            hull.pop_back();
        }
        hull.pb(hull1[i]);
    }
    for(int i = 1; i < hull2.size(); i++) {
        while(hull.size() > 1 && !is_clockwise(hull[hull.size() - 2], hull.back(), hull2[i])) {
            hull.pop_back();
        }
        hull.pb(hull2[i]);
    }
    sort(all(hull));
    hull.resize(unique(all(hull)) - hull.begin());
    give_answer(hull.size());
}

signed main() {
    solve();
}

Compilation message

tri.cpp: In function 'void find_hull(std::vector<int>&, std::vector<int>&)':
tri.cpp:30:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i = 2; i < p.size(); i++) {
      |                    ~~^~~~~~~~~~
tri.cpp: In function 'void solve()':
tri.cpp:59:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(int i = 1; i < hull1.size(); i++) {
      |                    ~~^~~~~~~~~~~~~~
tri.cpp:65:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for(int i = 1; i < hull2.size(); i++) {
      |                    ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -