답안 #95456

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
95456 2019-02-01T10:15:17 Z forestryks Printed Circuit Board (CEOI12_circuit) C++14
5 / 100
100 ms 4344 KB
///////////////////////////////////////////////////////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define FILE_IO(x) freopen((string(x) + ".in").c_str(), "r", stdin); freopen((string(x) + ".out").c_str(), "w", stdout)
#define f first
#define s second
#define x1 x1qwer
#define y1 y1qwer
#define right right123
#define left left123
#define foreach(it, v) for (auto it : v)
#define rep(it, n) for (int it = 0; it < n; ++it)
#define forin(it, l, r) for (int it = l; it < r; ++it)
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const double DINF = numeric_limits<double>::infinity();
const ll MOD = 1e9 + 7;
const double EPS = 1e-7;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
mt19937 mmtw_(MOD);
uniform_int_distribution<ll> rd_;
ll randomll() { return rd_(mmtw_);}
ll rnd(ll x, ll y) { return rd_(mmtw_) % (y - x + 1) + x; }
////////////////////////////////////////////////////////////////////////////////////////////////

struct pt {
    int x, y;
    int id;
};

inline pt operator-(const pt &a) {
    return {-a.x, -a.y};
}

inline pt operator-(const pt &a, const pt &b) {
    return {a.x - b.x, a.y - b.y};
}

inline ll dot(const pt &a, const pt &b) {
    return 1LL * a.x * b.x + 1LL * a.y * b.y;
}

inline ll cross(const pt &a, const pt &b) {
    return 1LL * a.x * b.y - 1LL * a.y * b.x;
}

inline ll dd0(const pt &a) {
    return dot(a, a);
}

const int MAXN = 1e5 + 5;
int n;
pt a[MAXN];

inline int md(int x) {
    if (x >= n) return x - n;
    if (x < 0) return x + n;
    return x;
}

int findLowest() {
    int s = 0;
    for (int i = 0; i < n; ++i) {
        ll cr = cross(a[i], a[s] - a[i]);
        if (cr > 0 || (cr == 0 && dd0(a[i]) < dd0(a[s]))) {
            s = i;
        }
    }
    return s;
}

int findHighest() {
    int t = 0;
    for (int i = 0; i < n; ++i) {
        ll cr = cross(a[i], a[t] - a[i]);
        if (cr < 0 || (cr == 0 && dd0(a[i]) < dd0(a[t]))) {
            t = i;
        }
    }
    return t;
}

struct seg {
    pt a, b;
};
seg s[MAXN];

bool inter(const pt &a, const seg &b) {
    if (!(cross(a, b.b) >= 0 && cross(a, b.a) <= 0)) return false;
    if (!(cross(b.b - b.a, a - b.a) <= 0 && cross(b.b - b.a, -b.a) >= 0)) return false;
    return true;
}

bool check(const pt &a, int sg) {
    for (int i = 0; i < n; ++i) {
        if (i == sg) continue;
        if (inter(a, s[i])) return false;
    }
    return true;
}

vector<int> solve() {
    vector<int> res;

    for (int i = 0; i < n; ++i) {
        if (check(s[i].a, i)) res.push_back(s[i].a.id);
        if (check(s[i].b, i)) res.push_back(s[i].b.id);
    }

    sort(all(res));
    res.erase(unique(all(res)), res.end());
    return res;
}

int main() {
    FAST_IO;
    cin >> n;
    rep(i, n) {
        cin >> a[i].x >> a[i].y;
        a[i].id = i + 1;
    }

    assert(n > 2);

    int lowest = findLowest();
    if (cross(a[md(lowest - 1)] - a[lowest], a[md(lowest + 1)] - a[lowest]) < 0) {
        reverse(a, a + n);
    }

    rotate(a, a + findLowest(), a + n);
    n = findHighest() + 1;

    int sz = 0;
    for (int i = 0; i + 1 < n; ++i) {
        if (cross(a[i], a[i + 1] - a[i]) > 0) s[sz++] = {a[i], a[i + 1]};
    }
    n = sz;

    vector<int> ans = solve();

    cout << ans.size() << '\n';
    for (auto it : ans) {
        cout << it << ' ';
    } cout << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 508 KB Output isn't correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Incorrect 25 ms 508 KB Output isn't correct
4 Incorrect 43 ms 504 KB Output isn't correct
5 Incorrect 52 ms 632 KB Output isn't correct
6 Incorrect 52 ms 632 KB Output isn't correct
7 Execution timed out 238 ms 1272 KB Time limit exceeded
8 Incorrect 24 ms 632 KB Output isn't correct
9 Correct 99 ms 760 KB Output is correct
10 Incorrect 65 ms 888 KB Output isn't correct
11 Incorrect 70 ms 760 KB Output isn't correct
12 Execution timed out 112 ms 1048 KB Time limit exceeded
13 Execution timed out 335 ms 1528 KB Time limit exceeded
14 Execution timed out 233 ms 1628 KB Time limit exceeded
15 Execution timed out 487 ms 2168 KB Time limit exceeded
16 Execution timed out 1069 ms 3708 KB Time limit exceeded
17 Execution timed out 1080 ms 3576 KB Time limit exceeded
18 Runtime error 22 ms 4216 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 22 ms 4220 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 23 ms 4344 KB Execution killed with signal 11 (could be triggered by violating memory limits)