답안 #369181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
369181 2021-02-20T18:15:05 Z denkendoemeer Dragon 2 (JOI17_dragon2) C++14
60 / 100
4000 ms 5252 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;
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    int i;
    for(i=0;i<n;i++){
        int a,b,c;
        cin>>a>>b>>c;
        g[c].push_back({{a,b},0,0});
    }
    pct s,t;
    cin>>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;
    cin>>q;
    for(i=1;i<=q;i++){
        int a,b;
        cin>>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++;
                }
            }
        }
        cout<<ans<<'\n';
    }
return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 2944 KB Output is correct
2 Correct 27 ms 2944 KB Output is correct
3 Correct 39 ms 2924 KB Output is correct
4 Correct 40 ms 3052 KB Output is correct
5 Correct 35 ms 3180 KB Output is correct
6 Correct 4 ms 2796 KB Output is correct
7 Correct 4 ms 2796 KB Output is correct
8 Correct 11 ms 2924 KB Output is correct
9 Correct 10 ms 2924 KB Output is correct
10 Correct 11 ms 2944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1737 ms 4216 KB Output is correct
2 Correct 3328 ms 4484 KB Output is correct
3 Correct 69 ms 4716 KB Output is correct
4 Correct 24 ms 4588 KB Output is correct
5 Correct 25 ms 4204 KB Output is correct
6 Correct 596 ms 4040 KB Output is correct
7 Correct 592 ms 4040 KB Output is correct
8 Correct 707 ms 4036 KB Output is correct
9 Correct 655 ms 4196 KB Output is correct
10 Correct 714 ms 4192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 2944 KB Output is correct
2 Correct 27 ms 2944 KB Output is correct
3 Correct 39 ms 2924 KB Output is correct
4 Correct 40 ms 3052 KB Output is correct
5 Correct 35 ms 3180 KB Output is correct
6 Correct 4 ms 2796 KB Output is correct
7 Correct 4 ms 2796 KB Output is correct
8 Correct 11 ms 2924 KB Output is correct
9 Correct 10 ms 2924 KB Output is correct
10 Correct 11 ms 2944 KB Output is correct
11 Correct 1737 ms 4216 KB Output is correct
12 Correct 3328 ms 4484 KB Output is correct
13 Correct 69 ms 4716 KB Output is correct
14 Correct 24 ms 4588 KB Output is correct
15 Correct 25 ms 4204 KB Output is correct
16 Correct 596 ms 4040 KB Output is correct
17 Correct 592 ms 4040 KB Output is correct
18 Correct 707 ms 4036 KB Output is correct
19 Correct 655 ms 4196 KB Output is correct
20 Correct 714 ms 4192 KB Output is correct
21 Correct 1735 ms 4040 KB Output is correct
22 Correct 3322 ms 4336 KB Output is correct
23 Correct 2374 ms 4972 KB Output is correct
24 Correct 666 ms 5252 KB Output is correct
25 Correct 66 ms 4588 KB Output is correct
26 Correct 57 ms 4332 KB Output is correct
27 Correct 25 ms 4076 KB Output is correct
28 Correct 25 ms 4204 KB Output is correct
29 Execution timed out 4040 ms 4240 KB Time limit exceeded
30 Halted 0 ms 0 KB -