답안 #230813

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230813 2020-05-11T21:07:52 Z walnutwaldo20 Relay (COI16_relay) C++14
37 / 100
2000 ms 6892 KB
#include <bits/stdc++.h>

#define F0R(i, a) for (int i = 0; i < (int)(a); i++)

#define PB push_back
#define MP make_pair
#define X real()
#define Y imag()

#define F first
#define S second

using namespace std;

typedef long long ll;
typedef complex<ll> point;
typedef pair<point, point> edge;

#define MAXN 100000

bool prereaches[MAXN];
bool reaches[MAXN];

edge rev(edge e) { return MP(e.S, e.F); }

ll crossp(point p1, point p2) {
    return (conj(p1) * p2).Y;
}

bool rightof(point p, edge e) {
    bool ret = crossp(e.S - e.F, p - e.S) <= 0;
    return ret;
}

point get(vector<point>& v, int idx) {
    return v[(idx % (int)v.size() + (int)v.size()) % (int)v.size()];
}

point findtangent(vector<point>&hull, point p, bool seen1, bool seen2) {
    F0R(i, hull.size()) {
        edge edge1 = MP(get(hull, i - 1), hull[i]);
        edge edge2 = MP(hull[i], get(hull, i + 1));
        if (rightof(p, edge1) == seen1 && rightof(p, edge2) == seen2) {
            return hull[i];
        }
    }
    cout << "this should not print" << endl;
    exit(0);
}

bool inside(point p, vector<point>& hull) {
    F0R(i, hull.size()) {
        edge e = MP(hull[i], get(hull, i + 1));
        if (rightof(p, e)) {
            return false;
        }
    }
    return true;
}

void read(int& len, vector<point>& vec) {
    cin >> len;
    F0R(i, len) {
        ll x, y;
        cin >> x >> y;
        vec.PB(point(x, y));
    }
}

vector<point> v, hull;
vector<point> ls, rs;

bool cansee(int i, int j) {
    if (rightof(v[j], MP(v[i], rs[i])) || rightof(v[j], MP(ls[i], v[i]))) {
        return true;
    }
    vector<point> triangle;
    triangle.PB(v[i]);
    triangle.PB(rs[i]);
    triangle.PB(ls[i]);
    return inside(v[j], triangle);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    read(n, v);
    read(m, hull);
    
    F0R(i, n) ls.PB(findtangent(hull, v[i], false, true));
    F0R(i, n) rs.PB(findtangent(hull, v[i], true, false));
    
    vector<int> v2;
    F0R(i, n) if (cansee(i, 0)) {
        v2.PB(i);
    }
    F0R(i, n) for (const int j : v2) {
        if (cansee(j, i)) {
            reaches[i] = true;
        }
    }
    
    int res = 0;
    F0R(i, n) if (reaches[i]) {
        res++;
    }
    cout << res - 1 << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 8 ms 384 KB Output is correct
7 Correct 10 ms 384 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 8 ms 384 KB Output is correct
7 Correct 10 ms 384 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 329 ms 796 KB Output is correct
12 Correct 350 ms 888 KB Output is correct
13 Correct 227 ms 760 KB Output is correct
14 Correct 407 ms 632 KB Output is correct
15 Correct 199 ms 632 KB Output is correct
16 Correct 277 ms 632 KB Output is correct
17 Correct 217 ms 760 KB Output is correct
18 Correct 356 ms 632 KB Output is correct
19 Correct 96 ms 632 KB Output is correct
20 Correct 88 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 8 ms 384 KB Output is correct
7 Correct 10 ms 384 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Execution timed out 2095 ms 6892 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 8 ms 384 KB Output is correct
7 Correct 10 ms 384 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 329 ms 796 KB Output is correct
12 Correct 350 ms 888 KB Output is correct
13 Correct 227 ms 760 KB Output is correct
14 Correct 407 ms 632 KB Output is correct
15 Correct 199 ms 632 KB Output is correct
16 Correct 277 ms 632 KB Output is correct
17 Correct 217 ms 760 KB Output is correct
18 Correct 356 ms 632 KB Output is correct
19 Correct 96 ms 632 KB Output is correct
20 Correct 88 ms 760 KB Output is correct
21 Execution timed out 2095 ms 6892 KB Time limit exceeded
22 Halted 0 ms 0 KB -