Submission #484488

#TimeUsernameProblemLanguageResultExecution timeMemory
484488jhnah917Dragon 2 (JOI17_dragon2)C++14
100 / 100
2497 ms3824 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...