답안 #369309

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
369309 2021-02-21T09:16:48 Z denkendoemeer Dragon 2 (JOI17_dragon2) C++14
60 / 100
4000 ms 5100 KB
#include<cstdio>
#include<cmath>
#include<vector>
#include<iostream>
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){
                    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<<endl;
    }
return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 2924 KB Output is correct
2 Correct 28 ms 2972 KB Output is correct
3 Correct 50 ms 2924 KB Output is correct
4 Correct 254 ms 3180 KB Output is correct
5 Correct 242 ms 3248 KB Output is correct
6 Correct 8 ms 2796 KB Output is correct
7 Correct 8 ms 2796 KB Output is correct
8 Correct 10 ms 2924 KB Output is correct
9 Correct 10 ms 2952 KB Output is correct
10 Correct 10 ms 2924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1757 ms 4216 KB Output is correct
2 Correct 3446 ms 4556 KB Output is correct
3 Correct 69 ms 4716 KB Output is correct
4 Correct 29 ms 4588 KB Output is correct
5 Correct 26 ms 4204 KB Output is correct
6 Correct 593 ms 4056 KB Output is correct
7 Correct 593 ms 4184 KB Output is correct
8 Correct 669 ms 4164 KB Output is correct
9 Correct 652 ms 4196 KB Output is correct
10 Correct 697 ms 4052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 2924 KB Output is correct
2 Correct 28 ms 2972 KB Output is correct
3 Correct 50 ms 2924 KB Output is correct
4 Correct 254 ms 3180 KB Output is correct
5 Correct 242 ms 3248 KB Output is correct
6 Correct 8 ms 2796 KB Output is correct
7 Correct 8 ms 2796 KB Output is correct
8 Correct 10 ms 2924 KB Output is correct
9 Correct 10 ms 2952 KB Output is correct
10 Correct 10 ms 2924 KB Output is correct
11 Correct 1757 ms 4216 KB Output is correct
12 Correct 3446 ms 4556 KB Output is correct
13 Correct 69 ms 4716 KB Output is correct
14 Correct 29 ms 4588 KB Output is correct
15 Correct 26 ms 4204 KB Output is correct
16 Correct 593 ms 4056 KB Output is correct
17 Correct 593 ms 4184 KB Output is correct
18 Correct 669 ms 4164 KB Output is correct
19 Correct 652 ms 4196 KB Output is correct
20 Correct 697 ms 4052 KB Output is correct
21 Correct 1744 ms 4168 KB Output is correct
22 Correct 3369 ms 4340 KB Output is correct
23 Correct 2430 ms 5044 KB Output is correct
24 Correct 916 ms 5100 KB Output is correct
25 Correct 283 ms 4588 KB Output is correct
26 Correct 276 ms 4356 KB Output is correct
27 Correct 56 ms 4076 KB Output is correct
28 Correct 57 ms 4076 KB Output is correct
29 Execution timed out 4054 ms 4648 KB Time limit exceeded
30 Halted 0 ms 0 KB -