QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#871498#8614. 3Ducup-team6275#TL 110ms4096kbC++234.3kb2025-01-25 20:54:292025-01-25 20:54:34

Judging History

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

  • [2025-01-25 20:54:34]
  • 评测
  • 测评结果:TL
  • 用时:110ms
  • 内存:4096kb
  • [2025-01-25 20:54:29]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, n) for (int i = 0; i < (n); i += 1)
#define len(a) ((int)(a).size())

mt19937_64 rnd(time(0));
mt19937 rndint(time(0) + 10);
const ll inf = 1e18;

const int SZ = 11;
const ld eps = 1e-9;
ld d[SZ][SZ];
int n;

struct pt {
    ld x, y, z;

    ld ln() {
        return sqrtl(x * x + y * y + z * z);
    }

    pt operator+(const pt &rht) {
        return {x + rht.x, y + rht.y, z + rht.z};
    }

    pt operator-(const pt &rht) {
        return {x - rht.x, y - rht.y, z - rht.z};
    }

    pt operator*(ld fuck) {
        return {x * fuck, y * fuck, z * fuck};
    }

    pt norm(ld a = 1) {
        ld nrm = a / ln();
        return {x * nrm, y * nrm, z * nrm};
    }
};
vector<pt> pts;

ld distsq(const pt &a, const pt &b) {
    return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) + (a.z - b.z) * (a.z - b.z);
}

ld dist(const pt &a, const pt &b) {
    return sqrtl(distsq(a, b));
}

ld get_random_ld() {
    const ll mod = 1e15;
    return rnd() % mod / (ld)(mod - 1);
}

int check(int v) {
    int res = 0;
    for (int i = 0; i < n; ++i) {
        if (i != v && abs(dist(pts[i], pts[v]) - d[i][v]) > 0.1 - eps)
            ++res;
    }
    return res;
}

int32_t main() {
    if (1) {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    cin >> n;

#ifdef LOCAL
    vector<pt> genpts(n);
    for (int i = 0; i < n; ++i) {
        genpts[i].x = get_random_ld();
        genpts[i].y = get_random_ld();
        genpts[i].z = get_random_ld();
    }

    for (int i = 0; i < n; ++i) {
        d[i][i] = 0;
        for (int j = i + 1; j < n; ++j) {
            d[i][j] = dist(genpts[i], genpts[j]) - (get_random_ld() - 0.5) / 5;
            d[j][i] = d[i][j];
        }
    }

#else
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j)
            cin >> d[i][j];
    }
#endif

    while (true) {
        pts.resize(n);
        vector<vector<ld>> ws(n, vector<ld>(n));
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                ws[i][j] = get_random_ld() + 0.5;
            }
        }
        for (int i = 0; i < n; ++i) {
            pts[i].x = get_random_ld();
            pts[i].y = get_random_ld();
            pts[i].z = get_random_ld();
        }

        int cnt_bad = 0;
        for (int i = 0; i < n; ++i)
            cnt_bad += check(i);

        cnt_bad /= 2;
        int iters = 0;

        bool fail = false;
        while (cnt_bad) {
            int v = rndint() % n;
            cnt_bad -= check(v);
            pt cur = {0, 0, 0};
            ld normed = 0;
            for (int i = 0; i < n; ++i) {
                if (i == v)
                    continue;

                pt yp = pts[i] + (pts[v] - pts[i]).norm(d[v][i]), ypp = pts[i] - (pts[v] - pts[i]).norm(d[v][i]);
                if (dist(yp, pts[v]) > dist(ypp, pts[v]))
                    yp = ypp;

                cur = cur + yp * ws[i][v];
                normed += ws[i][v];
            }
            cur = cur * (1 / normed);
            pts[v] = cur;
            cnt_bad += check(v);

            if (iters % 100 == 0) {
                cnt_bad = 0;
                for (int i = 0; i < n; ++i) {
                    cnt_bad += check(i);
                }
                cnt_bad /= 2;
            }

            ++iters;
            if (iters >= 50000) {
                fail = true;
                break;
            }
        }

        if (fail)
            continue;

#ifdef LOCAL
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                cout << setprecision(10) << fixed << dist(pts[i], pts[j]) << " ";
            }
            cout << "\n";
        }
#endif

        pt avg = {0, 0, 0};
        for (auto c : pts) {
            avg = avg + c;
        }
        avg.x /= n;
        avg.y /= n;
        avg.z /= n;

        for (auto c : pts) {
            c = c - avg;
            cout << setprecision(20) << fixed << c.x << " " << c.y << " " << c.z << "\n";
        }
        break;
    }

    return 0;
}

詳細信息

Test #1:

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

input:

4
0.000000 0.758400 0.557479 0.379026
0.758400 0.000000 0.516608 0.446312
0.557479 0.516608 0.000000 0.554364
0.379026 0.446312 0.554364 0.000000

output:

0.25299501455856113918 0.27590362017970485590 -0.08367908820629083318
-0.36554181253154999914 -0.06104157065285696209 0.12201394609542694247
-0.05437004924267419264 -0.11397895532807653831 -0.22246789280184101358
0.16691684721566305244 -0.10088309419877135553 0.18413303491270490429

result:

ok OK. Max delta: 0.091262

Test #2:

score: 0
Accepted
time: 1ms
memory: 4096kb

input:

1
0.000000

output:

0.00000000000000000000 0.00000000000000000000 0.00000000000000000000

result:

ok OK. Max delta: 0.000000

Test #3:

score: 0
Accepted
time: 0ms
memory: 3968kb

input:

2
0.000000 0.938096
0.938096 0.000000

output:

-0.35528591006087365645 0.30543502295402733684 -0.02207702809006658424
0.35528591006087365645 -0.30543502295402733682 0.02207702809006658419

result:

ok OK. Max delta: 0.000000

Test #4:

score: 0
Accepted
time: 1ms
memory: 4096kb

input:

3
0.000000 0.769195 0.308169
0.769195 0.000000 0.686850
0.308169 0.686850 0.000000

output:

0.13464520218854426887 -0.24687222418465488157 0.06249323747147834485
-0.32553435227066941383 0.16923586579015831280 -0.25638972358033228999
0.19088915008212514491 0.07763635839449656875 0.19389648610885394501

result:

ok OK. Max delta: 0.071630

Test #5:

score: 0
Accepted
time: 1ms
memory: 4096kb

input:

5
0.000000 0.444506 0.292333 0.209539 1.195824
0.444506 0.000000 0.220873 0.748833 0.757486
0.292333 0.220873 0.000000 0.533499 0.797167
0.209539 0.748833 0.533499 0.000000 1.141148
1.195824 0.757486 0.797167 1.141148 0.000000

output:

0.07490752487857240812 0.30397281689477818195 -0.17358713161661244842
0.07059996321397579402 -0.20723526617520831059 -0.15463097468363847252
-0.06441698794345765482 -0.02963094856606281684 -0.19726432415471664579
-0.04997255686812612911 0.45609157785364944819 -0.01363401481310254308
-0.0311179432809...

result:

ok OK. Max delta: 0.098828

Test #6:

score: 0
Accepted
time: 0ms
memory: 4096kb

input:

6
0.000000 0.932377 0.787009 0.996894 0.763544 0.651377
0.932377 0.000000 0.421278 1.155673 1.149686 0.508563
0.787009 0.421278 0.000000 0.709021 0.793974 0.224884
0.996894 1.155673 0.709021 0.000000 0.392548 0.957498
0.763544 1.149686 0.793974 0.392548 0.000000 0.714079
0.651377 0.508563 0.224884 0...

output:

0.44565176926433199976 -0.27714195771192898281 0.01399927684788031308
0.13028499469560334933 0.36428120849322845988 0.50050504776752182800
-0.20843278731044402211 0.11658613932178616242 0.19887012831006917090
-0.20093472827489482826 0.12162340490806189121 -0.55114898817712637113
-0.06400478431064864...

result:

ok OK. Max delta: 0.095506

Test #7:

score: 0
Accepted
time: 0ms
memory: 3968kb

input:

7
0.000000 0.688481 0.455407 0.777049 0.963980 0.255052 0.554599
0.688481 0.000000 0.596921 0.827787 1.260207 0.340235 0.493011
0.455407 0.596921 0.000000 0.609173 0.640567 0.352193 0.243913
0.777049 0.827787 0.609173 0.000000 0.858134 0.701131 0.393303
0.963980 1.260207 0.640567 0.858134 0.000000 0...

output:

-0.29385149586755382058 0.26589720138210206949 -0.00918720727380189421
-0.29334964562987107095 -0.27746987796884574091 -0.35391985446509871430
0.11886028059436201635 0.01031328152963552957 -0.01582294038931229325
0.04395234989768704179 -0.22655838125706325363 0.46051018591501005216
0.618579116172214...

result:

ok OK. Max delta: 0.095348

Test #8:

score: 0
Accepted
time: 1ms
memory: 4096kb

input:

8
0.000000 0.437494 0.934265 0.074097 0.673669 0.425700 0.479212 0.679270
0.437494 0.000000 0.331045 0.393801 0.527073 0.402792 0.375134 0.461133
0.934265 0.331045 0.000000 0.792317 0.605663 0.880433 0.786178 0.455534
0.074097 0.393801 0.792317 0.000000 0.681633 0.278020 0.327267 0.550058
0.673669 0...

output:

0.00375723512934348215 -0.15520884028796285597 -0.34332277819527270410
-0.03778262185478385097 0.07999886768190875210 0.11261635571471995517
-0.29914105882983207317 0.08948932023397507054 0.45413865474899174374
0.07914485177927571284 -0.14938458129470031834 -0.21236953887122126681
-0.236148380981383...

result:

ok OK. Max delta: 0.099113

Test #9:

score: 0
Accepted
time: 1ms
memory: 4096kb

input:

9
0.000000 0.883128 0.449200 0.525234 0.745161 0.323207 0.430759 1.247103 0.564870
0.883128 0.000000 0.664206 0.590150 0.433578 0.890708 0.741718 0.798316 1.033522
0.449200 0.664206 0.000000 0.326949 0.636800 0.523900 0.642051 0.680925 0.349474
0.525234 0.590150 0.326949 0.000000 0.523965 0.344241 0...

output:

-0.03977458210731361145 0.39700727357576549073 0.21789224961073296703
-0.26565452331154666980 -0.21333175728032716227 -0.44404846645563754356
0.05009098013018304589 -0.07975951296775060157 0.17578960068028601034
-0.25722051166896977098 0.04879292647043029238 0.06780953187712744610
-0.004191969342730...

result:

ok OK. Max delta: 0.099530

Test #10:

score: 0
Accepted
time: 0ms
memory: 4096kb

input:

10
0.000000 1.141963 0.357381 0.960442 0.887799 0.393165 1.000015 0.883861 1.059968 0.666258
1.141963 0.000000 0.730979 0.430440 0.528721 0.822481 0.567380 0.334929 0.552413 0.840500
0.357381 0.730979 0.000000 0.861027 0.623726 0.216981 0.719423 0.558824 0.726378 0.310217
0.960442 0.430440 0.861027 ...

output:

0.58279488276009823005 -0.31202820219705647750 0.08799393914917778782
-0.43236751256355513066 0.20022718928129470590 -0.02846914661032017604
0.32657531890020114921 -0.03847576996013718449 0.05044026977754655335
-0.34813212017040003711 -0.13623211398124928739 -0.38595389001782061866
-0.22763863677439...

result:

ok OK. Max delta: 0.098877

Test #11:

score: 0
Accepted
time: 1ms
memory: 4096kb

input:

10
0.000000 0.508467 0.359704 0.705660 0.752608 0.632298 0.433047 0.541855 0.108842 0.652503
0.508467 0.000000 0.849608 0.542157 0.614068 0.673963 0.552462 0.470005 0.697815 0.822930
0.359704 0.849608 0.000000 0.832286 0.790254 0.844729 0.428335 0.707356 0.221649 0.447522
0.705660 0.542157 0.832286 ...

output:

0.02933909895862903659 0.13390747319484878333 0.23607098692051844740
-0.23290536623846810626 -0.34174771774235287373 0.10481681044253644264
0.24083152025648487920 0.35975416106225090006 0.07786864185713136710
0.07918817712177555863 -0.35231089757552446815 -0.29109276720021993957
-0.25872409427133209...

result:

ok OK. Max delta: 0.099732

Test #12:

score: 0
Accepted
time: 20ms
memory: 4096kb

input:

10
0.000000 0.532841 1.081715 0.791902 0.304710 0.943952 0.318604 0.512618 0.263399 0.317304
0.532841 0.000000 0.617254 0.571776 0.863445 0.644868 0.534570 0.898453 0.767957 0.380512
1.081715 0.617254 0.000000 0.498716 1.118400 0.375946 0.739541 1.081104 0.985516 0.778030
0.791902 0.571776 0.498716 ...

output:

0.11422283178475960201 0.10203329877493591775 0.35336297631381911519
-0.17092652349623942479 -0.36035973566572576896 0.16348179211401900660
-0.34035561682469572058 -0.39603401322232994122 -0.41855720963694710319
0.03194611665523208787 -0.19020988876477909273 -0.40280800705521225831
0.108760827958392...

result:

ok OK. Max delta: 0.099868

Test #13:

score: 0
Accepted
time: 1ms
memory: 4096kb

input:

10
0.000000 0.337812 0.820740 0.714576 0.958294 1.114603 1.052855 0.816204 0.921684 0.581533
0.337812 0.000000 0.588126 0.550959 0.851936 1.076003 0.824637 0.634512 0.630209 0.781504
0.820740 0.588126 0.000000 0.754545 0.853344 0.651402 0.625435 0.521290 0.463145 0.927492
0.714576 0.550959 0.754545 ...

output:

0.27945454875557570253 -0.11688561568846120384 0.53720013762323510950
0.05984557912704036983 0.09887435733409628206 0.44072815397176764193
-0.11231331082345711869 0.41817833492315114322 0.00596168423049205442
0.51348831289389062523 0.08620015336451380771 -0.02563123412987953017
-0.345959732515712985...

result:

ok OK. Max delta: 0.099766

Test #14:

score: 0
Accepted
time: 110ms
memory: 3968kb

input:

10
0.000000 0.157221 0.630350 0.940948 0.790907 0.666502 0.536584 0.506196 0.353744 0.642539
0.157221 0.000000 0.582092 1.279081 0.812532 0.810677 0.850103 0.865478 0.320962 0.694578
0.630350 0.582092 0.000000 1.171965 1.045437 1.168568 0.582206 0.854963 0.513105 1.137099
0.940948 1.279081 1.171965 ...

output:

0.19379785143249265501 -0.10322815067128034646 0.23681210428619487381
0.11328833492633243668 -0.16575226696730501131 0.47285105403338356284
0.08244344435821329876 0.45889894148567928335 0.48280645323415032297
0.34267660505268787740 0.21751394337009345026 -0.62319749753646669409
-0.481843905335481891...

result:

ok OK. Max delta: 0.099889

Test #15:

score: 0
Accepted
time: 0ms
memory: 4096kb

input:

10
0.000000 0.655953 0.416075 0.956128 0.351321 0.411663 0.904277 0.786858 0.961004 1.159073
0.655953 0.000000 0.398507 0.430374 0.378366 0.531641 0.789955 0.396050 0.368849 1.088933
0.416075 0.398507 0.000000 0.976294 0.461240 0.328488 0.979923 0.705916 0.884932 1.254989
0.956128 0.430374 0.976294 ...

output:

-0.14304625618456244315 0.37043841346964771506 0.39752460065486299235
0.29597560463647984566 0.05989111222677831372 -0.06641335686527949174
0.19206075705889965401 0.52221092693803586955 0.04097981093005193025
0.23698364159249737059 -0.39315416175824972021 0.01255709919199189916
-0.046148812775649492...

result:

ok OK. Max delta: 0.099181

Test #16:

score: 0
Accepted
time: 17ms
memory: 3968kb

input:

10
0.000000 0.672245 0.576475 0.810904 0.599396 0.493165 0.431514 0.511677 0.859634 0.881368
0.672245 0.000000 1.249406 1.027657 0.113558 0.392208 0.862698 0.329856 1.012059 1.039747
0.576475 1.249406 0.000000 0.869439 1.254676 1.087547 0.535956 1.182094 0.744887 0.645939
0.810904 1.027657 0.869439 ...

output:

0.09775370806044790908 -0.29322424527700873825 -0.12003109887561807923
-0.50304610727785365869 -0.24566036304613285844 0.02089248325874778670
0.69967810495421997987 -0.09609352472721453879 -0.03185554421099131314
0.11027409588654425569 0.50705553733689174314 0.21574894818674044317
-0.478911769730708...

result:

ok OK. Max delta: 0.099945

Test #17:

score: 0
Accepted
time: 0ms
memory: 4096kb

input:

10
0.000000 0.609276 0.612588 0.898616 0.668529 0.802163 0.126104 0.681054 0.761434 0.310892
0.609276 0.000000 0.922363 0.423227 0.591390 0.662160 0.751720 0.241917 0.563127 0.693959
0.612588 0.922363 0.000000 0.873479 0.681583 0.707351 0.595097 0.923846 0.768951 0.393683
0.898616 0.423227 0.873479 ...

output:

-0.45694195454338809137 0.01106013553330687378 -0.12409136591153260344
0.15092066282776348018 -0.31040525724732280377 -0.28970360685599647220
-0.08332463917663456433 0.55389066327159001784 -0.11020030416777552062
0.37709057801899930365 -0.16742961884195447451 0.07501880706539053992
0.118775525559059...

result:

ok OK. Max delta: 0.098018

Test #18:

score: -100
Time Limit Exceeded

input:

10
0.000000 0.542508 0.426558 0.741404 0.733105 0.586307 0.271270 0.847645 0.757695 0.830800
0.542508 0.000000 0.497136 1.012191 1.083431 0.944439 0.618287 0.696705 0.472089 0.354373
0.426558 0.497136 0.000000 0.973354 0.928175 0.884683 0.594828 0.699473 0.534409 0.737409
0.741404 1.012191 0.973354 ...

output:


result: