QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#94532#5251. Constellationsmaomao90#WA 1611ms200312kbC++172.7kb2023-04-06 16:07:522023-04-06 16:07:55

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-06 16:07:55]
  • 评测
  • 测评结果:WA
  • 用时:1611ms
  • 内存:200312kb
  • [2023-04-06 16:07:52]
  • 提交

answer


// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h> 
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define RREP(i, s, e) for (int i = (s); i >= (e); i--)
template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
typedef __int128 ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define SZ(_a) (int) _a.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 4005;

struct star {
    ll x2, x1, y2, y1;
    int c, age;
    star operator+ (const star &o) const {
        return {x2 + o.x2, x1 + o.x2, y2 + o.y2, y1 + o.y1, c + o.c, 0};
    }
};

struct delta {
    ll num, denom;
    int mnage, mxage;
    delta(): num(0), denom(1), mnage(0), mxage(0) {}
    delta(star a, star b) {
        num = a.x2 * b.c - 2 * a.x1 * b.x1 + a.c * b.x2 +
            a.y2 * b.c - 2 * a.y1 * b.y1 + a.c * b.y2;
        denom = a.c * b.c;
        mnage = min(a.age, b.age);
        mxage = max(a.age, b.age);
    }
    bool operator> (const delta &o) const {
        if (num * o.denom == o.num * denom) {
            if (mnage == o.mnage) {
                return mxage > o.mxage;
            }
            return mnage > o.mnage;
        }
        return num * o.denom > o.num * denom;
    }
};

int n;
vector<star> stars;
priority_queue<delta, vector<delta>, greater<delta>> pq;
bool dead[MAXN];

int main() {
#ifndef DEBUG
    ios::sync_with_stdio(0), cin.tie(0);
#endif
    cin >> n;
    stars = vector<star>(n);
    REP (i, 0, n) {
        int x, y; cin >> x >> y;
        stars[i] = {x * x, x, y * y, y, 1, i};
    }
    REP (i, 0, n) {
        REP (j, i + 1, n) {
            pq.push(delta(stars[i], stars[j]));
        }
    }
    while (!pq.empty()) {
        delta top = pq.top(); pq.pop();
        int u = top.mnage, v = top.mxage;
        if (dead[u] || dead[v]) {
            continue;
        }
        dead[u] = 1; dead[v] = 1;
        star nstar = stars[u] + stars[v];
        nstar.age = SZ(stars);
        for (star s : stars) {
            if (dead[s.age]) {
                continue;
            }
            pq.push(delta(s, nstar));
        }
        stars.pb(nstar);
        cout << nstar.c << '\n';
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3420kb

input:

2
0 0
1 0

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 1611ms
memory: 200312kb

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'