QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#90529#5251. ConstellationsSolitaryDream#WA 1184ms134544kbC++201.4kb2023-03-23 14:48:482023-03-23 14:48:51

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-23 14:48:51]
  • 评测
  • 测评结果:WA
  • 用时:1184ms
  • 内存:134544kb
  • [2023-03-23 14:48:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define int long long

const int N=4e3+1e2+7;

int n,sx[N],sy[N],sxx[N],syy[N],c[N],x[N],y[N];

int cald(int a,int b)
{
    return sxx[a]+sxx[b]-2*sx[a]*sx[b]+syy[a]+syy[b]-2*sy[a]*sy[b];
}

int fa[N];

int find(int x)
{
    return x==fa[x]?x:fa[x]=find(fa[x]);
}

struct ND{
    int x,y;
    int A,B;
};

bool operator <(const ND &a,const ND &b)
{
    if(a.A*b.B!=b.A*a.B)
        return a.A*b.B>b.A*a.B;
    if(a.x!=b.x)
        return a.x>b.x;
    return a.y>b.y;
}

priority_queue<ND>q;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>x[i]>>y[i],fa[i]=i,sx[i]=x[i],sy[i]=y[i],sxx[i]=x[i]*x[i],syy[i]=y[i]*y[i],c[i]=1;
    
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            q.push({i,j,cald(i,j),c[i]*c[j]});
    int t=n;
    while(!q.empty())
    {
        auto [x,y,A,B]=q.top();
        q.pop();
        if(find(x)!=x||find(y)!=y)
            continue;
        ++t;
        fa[x]=t,fa[y]=t;
        fa[t]=t;
        c[t]=c[x]+c[y];
        sx[t]=sx[x]+sx[y];
        sy[t]=sy[x]+sy[y];
        sxx[t]=sxx[x]+sxx[y];
        syy[t]=syy[x]+syy[y];
        cout<<c[t]<<"\n";
        for(int i=1;i<t;i++)
            if(find(i)==i)
                q.push({i,t,cald(i,t),c[i]*c[t]});
    }
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3356kb

input:

2
0 0
1 0

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 1184ms
memory: 134544kb

input:

2000
1000 -1000
1000 -999
1000 -998
1000 -997
1000 -996
1000 -995
1000 -994
1000 -993
1000 -992
1000 -991
1000 -990
1000 -989
1000 -988
1000 -987
1000 -986
1000 -985
1000 -984
1000 -983
1000 -982
1000 -981
1000 -980
1000 -979
1000 -978
1000 -977
1000 -976
1000 -975
1000 -974
1000 -973
1000 -972
1000...

output:

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
10...

result:

wrong answer 2nd lines differ - expected: '2', found: '3'