# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
369180 | 2021-02-20T18:09:01 Z | denkendoemeer | Dragon 2 (JOI17_dragon2) | C++14 | 4000 ms | 6640 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long struct pct { ll x,y; pct operator - (pct aux) { return {x-aux.x,y-aux.y}; } ll operator * (pct aux) { return 1LL*x*aux.x+1LL*y*aux.y; } ll operator ^ (pct aux) { return 1LL*x*aux.y-1LL*y*aux.x; } }; struct aux { pct p; double a,b; bool ok; }; double unghi(pct x,pct y) { return ((x*y)/(hypotl(x.x,x.y)*hypotl(y.x,y.y))); } const double pi=acos(-1); vector<aux>g[100005]; int main() { //freopen(".in","r",stdin); //freopen(".out","w",stdout); int n,m; scanf("%d%d",&n,&m); int i; for(i=0;i<n;i++){ int a,b,c; scanf("%d%d%d",&a,&b,&c); g[c].push_back({{a,b},0,0}); } pct s,t; scanf("%lld%lld%lld%lld",&s.x,&s.y,&t.x,&t.y); for(i=1;i<=m;i++){ for(aux &it:g[i]){ it.a=unghi(it.p-s,t-s); it.b=unghi(it.p-t,s-t); if (((t-s)^(it.p-s))>0) it.ok=1; else it.ok=0; } } int q; scanf("%d",&q); for(i=1;i<=q;i++){ int a,b; scanf("%d%d",&a,&b); int ans=0; for(aux &it1:g[a]){ for(aux &it2:g[b]){ if (it1.ok==it2.ok){ if ((((it1.p-s)^(it2.p-s))>0)!=(((it1.p-t)^(it2.p-t))>0) && (((t-s)^(it2.p-s))>0)==(((it2.p-s)^(it1.p-s))>0)) ans++; } else{ if ((((it1.p-s)^(it2.p-s))>0)!=(((it1.p-t)^(it2.p-t))>0)) ans++; } } } printf("%d\n",ans); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 3052 KB | Output is correct |
2 | Correct | 28 ms | 2924 KB | Output is correct |
3 | Correct | 40 ms | 3052 KB | Output is correct |
4 | Correct | 48 ms | 3948 KB | Output is correct |
5 | Correct | 41 ms | 3948 KB | Output is correct |
6 | Correct | 5 ms | 2924 KB | Output is correct |
7 | Correct | 6 ms | 3052 KB | Output is correct |
8 | Correct | 11 ms | 2924 KB | Output is correct |
9 | Correct | 10 ms | 3052 KB | Output is correct |
10 | Correct | 11 ms | 2924 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1768 ms | 4880 KB | Output is correct |
2 | Correct | 3440 ms | 5068 KB | Output is correct |
3 | Correct | 73 ms | 5356 KB | Output is correct |
4 | Correct | 25 ms | 5356 KB | Output is correct |
5 | Correct | 28 ms | 4972 KB | Output is correct |
6 | Correct | 618 ms | 4680 KB | Output is correct |
7 | Correct | 609 ms | 4680 KB | Output is correct |
8 | Correct | 742 ms | 4804 KB | Output is correct |
9 | Correct | 667 ms | 4708 KB | Output is correct |
10 | Correct | 713 ms | 4644 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 3052 KB | Output is correct |
2 | Correct | 28 ms | 2924 KB | Output is correct |
3 | Correct | 40 ms | 3052 KB | Output is correct |
4 | Correct | 48 ms | 3948 KB | Output is correct |
5 | Correct | 41 ms | 3948 KB | Output is correct |
6 | Correct | 5 ms | 2924 KB | Output is correct |
7 | Correct | 6 ms | 3052 KB | Output is correct |
8 | Correct | 11 ms | 2924 KB | Output is correct |
9 | Correct | 10 ms | 3052 KB | Output is correct |
10 | Correct | 11 ms | 2924 KB | Output is correct |
11 | Correct | 1768 ms | 4880 KB | Output is correct |
12 | Correct | 3440 ms | 5068 KB | Output is correct |
13 | Correct | 73 ms | 5356 KB | Output is correct |
14 | Correct | 25 ms | 5356 KB | Output is correct |
15 | Correct | 28 ms | 4972 KB | Output is correct |
16 | Correct | 618 ms | 4680 KB | Output is correct |
17 | Correct | 609 ms | 4680 KB | Output is correct |
18 | Correct | 742 ms | 4804 KB | Output is correct |
19 | Correct | 667 ms | 4708 KB | Output is correct |
20 | Correct | 713 ms | 4644 KB | Output is correct |
21 | Correct | 1778 ms | 4680 KB | Output is correct |
22 | Correct | 3422 ms | 5004 KB | Output is correct |
23 | Correct | 2377 ms | 5944 KB | Output is correct |
24 | Correct | 684 ms | 6640 KB | Output is correct |
25 | Correct | 76 ms | 6252 KB | Output is correct |
26 | Correct | 79 ms | 6252 KB | Output is correct |
27 | Correct | 27 ms | 5100 KB | Output is correct |
28 | Correct | 27 ms | 5100 KB | Output is correct |
29 | Execution timed out | 4034 ms | 6160 KB | Time limit exceeded |
30 | Halted | 0 ms | 0 KB | - |