# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1240272 | PenguinsAreCute | Dragon 2 (JOI17_dragon2) | C++17 | 4091 ms | 35964 KiB |
#include <bits/stdc++.h>
using namespace std;
using cp = complex<long double>;
int main() {
int n, m;
cin >> n >> m;
vector<cp> dragon[m];
for(int i=0;i<n;i++) {
int a, b, c;
cin >> a >> b >> c;
dragon[c-1].push_back({a,b});
}
if(1) {
cp st, nd;
int d1, e1, d2, e2;
cin >> d1 >> e1 >> d2 >> e2;
st = cp(d1,e1);
nd = cp(d2,e2);
for(int i=0;i<m;i++)
for(auto &j: dragon[i])
j = (j - st) / (nd - st);
}
int ans[m][m];
memset(ans,0,sizeof(ans));
for(int i=0;i<m;i++)
for(auto c1: dragon[i])
for(int j=0;j<m;j++)
for(auto c2: dragon[j])
if((c2 / c1).imag() * c1.imag() < 0 && ((c2 - cp(1)) / (c1 - cp(1))).imag() * c1.imag() > 0)
ans[i][j]++;
int q;
cin >> q;
for(int f,g;q--;) {
cin >> f >> g;
f--; g--;
cout << ans[f][g] << "\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |