Submission #484488

# Submission time Handle Problem Language Result Execution time Memory
484488 2021-11-03T16:51:59 Z jhnah917 Dragon 2 (JOI17_dragon2) C++14
100 / 100
2497 ms 3824 KB
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int N, M, Q, S[30000], E[30000];
alignas(32) ll X[30000], Y[30000];
struct{ ll x, y, c; } V[30000], A, B;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N >> M;
    for(int i=0; i<N; i++) cin >> V[i].x >> V[i].y >> V[i].c, V[i].c--;
    cin >> A.x >> A.y >> B.x >> B.y;
    sort(V, V+N, [](auto a, auto b){ return a.c < b.c; });
    for(int i=0; i<N; i++) X[i] = V[i].x, Y[i] = V[i].y;
    memset(S, 0x3f, sizeof S);
    memset(E, 0xc0, sizeof E);
    for(int i=0; i<N; i++) S[V[i].c] = min(S[V[i].c], i), E[V[i].c] = max(E[V[i].c], i);
    cin >> Q;
    while(Q--){
        int a, b, res = 0; cin >> a >> b; a--; b--;
        for(int i=S[a]; i<=E[a]; i++){
            const ll aX = A.x - X[i], aY = A.y - Y[i];
            const ll bX = B.x - X[i], bY = B.y - Y[i];
            const ll dir = aX*bY - aY*bX;
            for(int j=S[b]; j<=E[b]; j++){
                const ll dX = X[j] - X[i], dY = Y[j] - Y[i];
                const ll cA = dX*aY - dY*aX, cB = dX*bY - dY*bX;
                if(dir >= 0) res += cA <= 0 && cB >= 0;
                else res += cA >= 0 && cB <= 0;
            }
        }
        cout << res << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 716 KB Output is correct
2 Correct 17 ms 716 KB Output is correct
3 Correct 18 ms 792 KB Output is correct
4 Correct 27 ms 1812 KB Output is correct
5 Correct 24 ms 1732 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
7 Correct 2 ms 716 KB Output is correct
8 Correct 8 ms 716 KB Output is correct
9 Correct 8 ms 720 KB Output is correct
10 Correct 8 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 709 ms 2372 KB Output is correct
2 Correct 1392 ms 2380 KB Output is correct
3 Correct 38 ms 2420 KB Output is correct
4 Correct 11 ms 2380 KB Output is correct
5 Correct 14 ms 2468 KB Output is correct
6 Correct 727 ms 2388 KB Output is correct
7 Correct 702 ms 2388 KB Output is correct
8 Correct 708 ms 2380 KB Output is correct
9 Correct 703 ms 2196 KB Output is correct
10 Correct 704 ms 2124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 716 KB Output is correct
2 Correct 17 ms 716 KB Output is correct
3 Correct 18 ms 792 KB Output is correct
4 Correct 27 ms 1812 KB Output is correct
5 Correct 24 ms 1732 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
7 Correct 2 ms 716 KB Output is correct
8 Correct 8 ms 716 KB Output is correct
9 Correct 8 ms 720 KB Output is correct
10 Correct 8 ms 716 KB Output is correct
11 Correct 709 ms 2372 KB Output is correct
12 Correct 1392 ms 2380 KB Output is correct
13 Correct 38 ms 2420 KB Output is correct
14 Correct 11 ms 2380 KB Output is correct
15 Correct 14 ms 2468 KB Output is correct
16 Correct 727 ms 2388 KB Output is correct
17 Correct 702 ms 2388 KB Output is correct
18 Correct 708 ms 2380 KB Output is correct
19 Correct 703 ms 2196 KB Output is correct
20 Correct 704 ms 2124 KB Output is correct
21 Correct 692 ms 2372 KB Output is correct
22 Correct 1355 ms 2380 KB Output is correct
23 Correct 1372 ms 2520 KB Output is correct
24 Correct 323 ms 3488 KB Output is correct
25 Correct 38 ms 3524 KB Output is correct
26 Correct 35 ms 3780 KB Output is correct
27 Correct 12 ms 2636 KB Output is correct
28 Correct 13 ms 2704 KB Output is correct
29 Correct 2497 ms 3824 KB Output is correct
30 Correct 64 ms 3524 KB Output is correct
31 Correct 34 ms 3688 KB Output is correct
32 Correct 52 ms 3524 KB Output is correct
33 Correct 400 ms 3720 KB Output is correct
34 Correct 33 ms 3652 KB Output is correct
35 Correct 33 ms 3608 KB Output is correct
36 Correct 35 ms 3508 KB Output is correct
37 Correct 35 ms 3772 KB Output is correct
38 Correct 706 ms 3724 KB Output is correct
39 Correct 571 ms 3712 KB Output is correct
40 Correct 403 ms 3528 KB Output is correct
41 Correct 1811 ms 3484 KB Output is correct
42 Correct 1176 ms 3652 KB Output is correct
43 Correct 948 ms 3740 KB Output is correct
44 Correct 1381 ms 2812 KB Output is correct
45 Correct 677 ms 2704 KB Output is correct
46 Correct 433 ms 2576 KB Output is correct
47 Correct 692 ms 2584 KB Output is correct
48 Correct 367 ms 2704 KB Output is correct
49 Correct 245 ms 2480 KB Output is correct