제출 #226254

#제출 시각아이디문제언어결과실행 시간메모리
226254dolphingarlicDragon 2 (JOI17_dragon2)C++14
100 / 100
2614 ms4088 KiB
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

struct Point {
    ll x, y;
} A, B;

inline bool ccw(Point X, Point Y, Point Z) {
    return (X.x - Y.x) * (Z.y - Y.y) <= (X.y - Y.y) * (Z.x - Y.x);
}

vector<Point> by_tribe[30000];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    FOR(i, 0, n) {
        Point p;
        int tribe;
        cin >> p.x >> p.y >> tribe;
        by_tribe[tribe - 1].push_back(p);
    }
    cin >> A.x >> A.y >> B.x >> B.y;

    int q;
    cin >> q;
    while (q--) {
        int x, y;
        cin >> x >> y;
        int ans = 0;
        for (Point i : by_tribe[x - 1]) for (Point j : by_tribe[y - 1]) {
            if (ccw(i, A, B)) ans += (ccw(i, A, j) && ccw(j, B, i));
            else ans += (ccw(j, A, i) && ccw(i, B, j));
        }
        cout << ans << '\n';
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...