Submission #369310

# Submission time Handle Problem Language Result Execution time Memory
369310 2021-02-21T09:19:34 Z denkendoemeer Dragon 2 (JOI17_dragon2) C++14
60 / 100
4000 ms 6380 KB
#include<cstdio>
#include<cmath>
#include<vector>
#include<iostream>
using namespace std;
#define ll long long
#define double long double
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){
                    ans=ans+(((((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)));
                }
                else{
                    ans=ans+((((it1.p-s)^(it2.p-s))>0)!=(((it1.p-t)^(it2.p-t))>0));

                }
            }
        }
        cout<<ans<<'\n';
    }
return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 19 ms 3052 KB Output is correct
2 Correct 27 ms 3052 KB Output is correct
3 Correct 39 ms 3052 KB Output is correct
4 Correct 40 ms 3180 KB Output is correct
5 Correct 33 ms 3180 KB Output is correct
6 Correct 4 ms 2924 KB Output is correct
7 Correct 4 ms 2924 KB Output is correct
8 Correct 11 ms 3052 KB Output is correct
9 Correct 10 ms 3052 KB Output is correct
10 Correct 10 ms 3052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1750 ms 4764 KB Output is correct
2 Correct 3323 ms 4856 KB Output is correct
3 Correct 69 ms 5740 KB Output is correct
4 Correct 25 ms 5868 KB Output is correct
5 Correct 29 ms 4972 KB Output is correct
6 Correct 613 ms 4740 KB Output is correct
7 Correct 620 ms 4740 KB Output is correct
8 Correct 695 ms 4824 KB Output is correct
9 Correct 649 ms 5348 KB Output is correct
10 Correct 692 ms 4836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 3052 KB Output is correct
2 Correct 27 ms 3052 KB Output is correct
3 Correct 39 ms 3052 KB Output is correct
4 Correct 40 ms 3180 KB Output is correct
5 Correct 33 ms 3180 KB Output is correct
6 Correct 4 ms 2924 KB Output is correct
7 Correct 4 ms 2924 KB Output is correct
8 Correct 11 ms 3052 KB Output is correct
9 Correct 10 ms 3052 KB Output is correct
10 Correct 10 ms 3052 KB Output is correct
11 Correct 1750 ms 4764 KB Output is correct
12 Correct 3323 ms 4856 KB Output is correct
13 Correct 69 ms 5740 KB Output is correct
14 Correct 25 ms 5868 KB Output is correct
15 Correct 29 ms 4972 KB Output is correct
16 Correct 613 ms 4740 KB Output is correct
17 Correct 620 ms 4740 KB Output is correct
18 Correct 695 ms 4824 KB Output is correct
19 Correct 649 ms 5348 KB Output is correct
20 Correct 692 ms 4836 KB Output is correct
21 Correct 1748 ms 4824 KB Output is correct
22 Correct 3328 ms 5084 KB Output is correct
23 Correct 2356 ms 5996 KB Output is correct
24 Correct 680 ms 6380 KB Output is correct
25 Correct 68 ms 5484 KB Output is correct
26 Correct 61 ms 5228 KB Output is correct
27 Correct 26 ms 5100 KB Output is correct
28 Correct 30 ms 5100 KB Output is correct
29 Execution timed out 4045 ms 5176 KB Time limit exceeded
30 Halted 0 ms 0 KB -