QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#109286#3001. Piece of CakeidontreallyknowWA 34ms3916kbC++171.2kb2023-05-28 09:30:102023-05-28 09:30:10

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-28 09:30:10]
  • 评测
  • 测评结果:WA
  • 用时:34ms
  • 内存:3916kb
  • [2023-05-28 09:30:10]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ld = long double;
ld read() {
    string s;
    cin >> s;
    return stold(s);
}
ld pt[2505][2], mul[2505];
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n,k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        pt[i][0] = read();
        pt[i][1] = read();
    }
    vector<int> ind(n);
    iota(ind.begin(),ind.end(),0);
    sort(ind.begin(),ind.end(),[&](int x, int y) {
        bool ba = make_pair(pt[x][0],pt[x][1]) < pair<ld,ld>{0,0}, bb = make_pair(pt[y][0],pt[y][1]) < pair<ld,ld>{0,0};
        if (ba != bb) return ba < bb;
        return pt[x][0]*pt[y][1] > pt[x][1]*pt[y][0];
    });
    ld tot = 0;
    for (int i = 0; i <= n-k; i++) {
        ld ret = k*(k-1)/2;
        for (int j = 0; j < k-2; j++) {
            ret *= n-i-2-j;
            ret /= n-j;
        }
        ret *= 2;
        ret /= ((n-k+2)*(n-k+1));
        ld cur = 0;
        for (int j = 0; j < n; j++) {
            int l = (j+i+1)%n;
            cur += pt[ind[j]][0]*pt[ind[l]][1]-pt[ind[j]][1]*pt[ind[l]][0];
        }
        tot += ret*cur;
    }
    cout << setprecision(20) << tot/2 << '\n';
    return 0;
}

详细

Test #1:

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

input:

3 3
-5.236334 -8.519438
-9.987847 -0.492878
-9.994555 0.329962

output:

1.9279463962200000006

result:

ok found '1.9279464', expected '1.9279464', error '0.0000000'

Test #2:

score: 0
Accepted
time: 34ms
memory: 3916kb

input:

2496 3
-9.999961 0.028130
-9.999655 0.083151
-9.999641 0.084830
-9.999572 0.092537
-9.999474 0.102653
-9.999366 0.112678
-9.999329 0.115862
-9.998360 0.181104
-9.998033 0.198381
-9.997191 0.237035
-9.995264 0.307754
-9.993680 0.355494
-9.992454 0.388414
-9.992180 0.395407
-9.992030 0.399190
-9.99086...

output:

47.714537070548314623

result:

ok found '47.7145371', expected '47.7145371', error '0.0000000'

Test #3:

score: 0
Accepted
time: 21ms
memory: 3604kb

input:

2099 1049
-9.999906 0.043015
-9.999734 0.072371
-9.999721 0.074260
-9.999602 0.089189
-9.999407 0.108349
-9.999328 0.115856
-9.998818 0.153747
-9.998136 0.193060
-9.997663 0.216208
-9.997463 0.225142
-9.996961 0.246480
-9.995978 0.282576
-9.995847 0.287087
-9.995567 0.296415
-9.994353 0.335674
-9.99...

output:

267.94895542030524022

result:

ok found '267.9489554', expected '267.9489554', error '0.0000000'

Test #4:

score: 0
Accepted
time: 3ms
memory: 3604kb

input:

342 171
-9.998818 0.153747
-9.997917 0.202726
-9.997663 0.216208
-9.986909 0.482051
-9.977066 0.669980
-9.960055 0.892895
-9.943677 1.059735
-9.924803 1.223737
-9.922265 1.244011
-9.881584 1.527686
-9.871340 1.595884
-9.813970 1.916653
-9.787551 2.050325
-9.745125 2.243053
-9.683458 2.495799
-9.6678...

output:

266.64419338279892205

result:

ok found '266.6441934', expected '266.6441934', error '0.0000000'

Test #5:

score: -100
Wrong Answer
time: 2ms
memory: 3600kb

input:

87 86
7.934712 5.851277
7.957370 5.901363
7.984885 5.912160
8.057904 5.888196
8.090706 5.871558
8.192155 5.734764
8.214245 5.702976
8.241768 5.663321
8.314438 5.556037
8.394960 5.433442
8.425523 5.386110
8.474268 5.308844
8.497539 5.271774
8.565648 5.160298
8.580590 5.135443
8.621362 5.066710
8.6895...

output:

2.7795413501504942512

result:

wrong answer 1st numbers differ - expected: '3.2268546', found: '2.7795414', error = '0.1386221'