QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#105366#5505. Great Chasecciafrino#WA 337ms15652kbC++171.9kb2023-05-13 23:18:242023-05-13 23:18:28

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-13 23:18:28]
  • 评测
  • 测评结果:WA
  • 用时:337ms
  • 内存:15652kb
  • [2023-05-13 23:18:24]
  • 提交

answer

#include <bits/stdc++.h>
//G
using namespace std;
double t, calc, enc, tn, tp, t2;
vector <double> polvn (400001);
vector <double> polpn (400001);
vector <double> polvp (400001);
vector <double> polpp (400001);

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    long long int z, n, nn, np, v, pi, vi, mpn, mpp, it, mvp, mvn;
    cin >> z;
    while (z--){
        it = 0;
        mpn = -100000000000000; 
        mpp = 100000000000000;
        np = 0;
        nn = 0;
        cin >> n >> v;
        while (n--){
            cin >> pi >> vi;
            if (pi < 0){
                polpn[nn] = pi;
                polvn[nn] = vi;
                if (pi > mpn){
                    mpn = pi;
                    mvn = vi;
                }
                nn ++;
            } else{
                polpp[np] = pi;
                polvp[np] = vi;
                if (pi < mpp){
                    mpp = pi;
                    mvp = vi;
                }
                np ++;
            }
        } 
        t = (mpp - mpn)*1.0/(mvp + mvn);
        tn = t;
        tp = t;
        while (it < 99){
            enc = mpn + t*mvn;
            for (int i = 0; i < np; i++){
                if ((polpp[i]- enc)/(1.0*polvp[i]) < tp){ 
                    tp = (abs(polpp[i] - enc))/(1.0*polvp[i]);
                    mpp = polpp[i];
                    mvp = polvp[i];
                }
            } for (int i = 0; i < nn; i++){
                if ((enc - polpn[i])/(1.0*polvn[i]) < tn){ 
                    tn = (abs(enc - polpn[i]))/(1.0*polvn[i]);
                    mpn = polpn[i];
                    mvn = polvn[i];
                }
            } t2 = (mpp - mpn)*1.0/(mvp + mvn);
            if (t - t2 < 0.00000001) break;
            it ++;
            t = t2;
        }
        cout << fixed << setprecision(8); 
        cout << t*v << "\n";

    } return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 10ms
memory: 15560kb

input:

3
4 9
10 2
-7 2
-6 1
7 1
2 8
-1 7
1 6
2 3
-1000000000000 1
1000000000000 1

output:

38.25000000
1.23076923
3000000000000.00000000

result:

ok 3 numbers

Test #2:

score: -100
Wrong Answer
time: 337ms
memory: 15652kb

input:

10000
200 997007
405524182320 754760
686939601648 419804
687047488212 715566
1446157132 4594
-670522037 4673
763634629282 253755
424307411732 275041
1582708381 8473
-667425982 4622
-522841486 1427
702430907988 460271
1405423646 1060
1497754648 6227
883363410675 723547
56899800372 46435
-810216390 64...

output:

149761465419.78952026
19466689816.48387146
5280325824.20548344
322225396.57134730
50171218552.27944946
183885744.76923075
2234417354.87092447
112796388806.31123352
14003668797.75848198
412975327.55555558
976630191.14446974
4721452454.74791145
352961619.38104385
5575125771.79879761
461840680.45120531...

result:

wrong answer 1st numbers differ - expected: '145405766328.3491211', found: '149761465419.7895203', error = '0.0299555'