QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#507164#6667. ProsjekPorNPtree0 253ms25056kbC++171.4kb2024-08-06 11:51:512024-08-06 11:51:52

Judging History

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

  • [2024-08-06 11:51:52]
  • 评测
  • 测评结果:0
  • 用时:253ms
  • 内存:25056kb
  • [2024-08-06 11:51:51]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 5;

int n;
long long a[N];
vector<long long> p[2];
mt19937 rnd;

int check() {
    p[0].clear(), p[1].clear();
    for (int i = 1; i <= n; ++i) {
        p[a[i] & 1].push_back(a[i]);
    }
    vector< pair<long long, long long> > tp;
    for (int i = 1; i < n; ++i) {
        if (p[0].size() < 2 && p[1].size() < 2) return 0;
        int t = rnd() & 1;
        if (p[t].size() >= 2) {
            tp.push_back({p[t].end()[-2], p[t].back()});
            long long v = (p[t].end()[-2] + p[t].back()) >> 1;
            p[t].pop_back(), p[t].pop_back(), p[v & 1].push_back(v);
            continue;
        }
        t ^= 1;
        if (p[t].size() >= 2) {
            tp.push_back({p[t].end()[-2], p[t].back()});
            long long v = (p[t].end()[-2] + p[t].back()) >> 1;
            p[t].pop_back(), p[t].pop_back(), p[v & 1].push_back(v);
        }
    }
    for (auto [x, y] : tp) printf("%lld %lld\n", x, y);
    return 1;
}

signed main() {
    int T; scanf("%d", &T);
    while (T--) {
        scanf("%d", &n);
        for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
        int flg = 0;
        for (int i = 0; i < 20; ++i) {
            shuffle(a + 1, a + n + 1, rnd);
            if (check()) {
                flg = 1;
                break;
            }
        }
        if (!flg) puts("-1");
    }
    return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 9
Accepted
time: 1ms
memory: 3848kb

input:

99
4
739880851158065302 19206582949872932 883064254701115295 222072661880779376
7
148399819461615003 209088712310207988 53191076581680214 445068618251612752 230505279594622109 115754892157516718 804173775829453588
2
77979357045500669 41693388829622019
3
341612949433488278 609808714829036935 19994167...

output:

739880851158065302 19206582949872932
883064254701115295 379543717053969117
222072661880779376 631303985877542206
209088712310207988 53191076581680214
230505279594622109 131139894445944101
148399819461615003 180822587020283105
445068618251612752 164611203240949054
115754892157516718 80417377582945358...

result:

ok correct (99 test cases)

Test #2:

score: 9
Accepted
time: 0ms
memory: 4112kb

input:

94
4
522567009208273608 11643656493074325 186427311250002481 123849906165842189
5
106161059262489233 415343718607892434 327977047389442178 962072443749424073 442437950417792236
2
183203550209212188 845051373320458660
4
438596026703410712 750951289026921248 112070483603621346 883810241305765624
4
145...

output:

186427311250002481 11643656493074325
123849906165842189 99035483871538403
522567009208273608 111442695018690296
962072443749424073 106161059262489233
415343718607892434 327977047389442178
442437950417792236 371660382998667306
534116751505956653 407049166708229771
183203550209212188 84505137332045866...

result:

ok correct (94 test cases)

Test #3:

score: 9
Accepted
time: 1ms
memory: 3808kb

input:

100
6
992926089095812859 592566222682195905 851047547791588090 117812034990980493 287668656568989067 500497313856354147
5
422579495815431679 738445394838743009 952584027249447301 804094328392164866 131591678779711861
6
671044256239146581 730689616081395646 623998023808544596 817401707748253055 55805...

output:

287668656568989067 592566222682195905
851047547791588090 440117439625592486
992926089095812859 500497313856354147
117812034990980493 746711701476083503
645582493708590288 432261868233531998
422579495815431679 738445394838743009
952584027249447301 131591678779711861
804094328392164866 580512445327087...

result:

ok correct (100 test cases)

Test #4:

score: 0
Wrong Answer
time: 1ms
memory: 3808kb

input:

100
3
3 3 2
3
4 1 1
4
1 3 4 4
6
4 4 2 3 1 2
4
0 2 1 4
3
0 2 0
7
3 3 1 1 3 4 0
2
0 4
4
1 4 2 3
7
4 0 0 3 2 3 4
4
4 2 0 3
7
0 2 2 1 4 2 4
7
3 0 3 1 2 0 3
4
4 3 1 4
6
2 3 0 1 3 4
5
1 4 0 3 4
5
4 2 0 4 2
3
0 1 2
6
4 1 4 2 0 4
7
4 2 4 3 1 3 1
4
1 4 4 0
2
1 1
6
0 3 3 0 0 4
7
4 3 0 3 3 3 4
4
4 1 1 3
6
2 0 ...

output:

-1
-1
4 4
1 3
4 2
2 4
3 3
1 3
2 2
4 2
4 2
1 3
0 2
0 0
2 0
4 0
3 3
1 3
2 2
1 3
2 2
0 4
2 4
3 3
1 3
0 4
0 2
3 1
2 2
4 2
3 3
2 0
3 1
4 2
4 2
0 4
2 2
2 2
1 3
2 2
3 3
2 0
3 1
1 3
2 2
0 2
4 4
1 3
4 2
3 3
1 3
0 2
4 2
1 3
0 4
4 2
3 3
1 3
2 0
4 4
2 4
1 3
2 0
1 1
0 4
4 2
1 3
2 2
4 2
4 2
1 3
1 3
2 2
4 2
3 3
4 ...

result:

wrong answer you didn't find a solution but jury did (test case 44)

Subtask #2:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 1ms
memory: 4104kb

input:

100
3
3 3 2
3
4 1 1
4
1 3 4 4
6
4 4 2 3 1 2
4
0 2 1 4
3
0 2 0
7
3 3 1 1 3 4 0
2
0 4
4
1 4 2 3
7
4 0 0 3 2 3 4
4
4 2 0 3
7
0 2 2 1 4 2 4
7
3 0 3 1 2 0 3
4
4 3 1 4
6
2 3 0 1 3 4
5
1 4 0 3 4
5
4 2 0 4 2
3
0 1 2
6
4 1 4 2 0 4
7
4 2 4 3 1 3 1
4
1 4 4 0
2
1 1
6
0 3 3 0 0 4
7
4 3 0 3 3 3 4
4
4 1 1 3
6
2 0 ...

output:

-1
-1
4 4
1 3
4 2
2 4
3 3
1 3
2 2
4 2
4 2
1 3
0 2
0 0
2 0
4 0
3 3
1 3
2 2
1 3
2 2
0 4
2 4
3 3
1 3
0 4
0 2
3 1
2 2
4 2
3 3
2 0
3 1
4 2
4 2
0 4
2 2
2 2
1 3
2 2
3 3
2 0
3 1
1 3
2 2
0 2
4 4
1 3
4 2
3 3
1 3
0 2
4 2
1 3
0 4
4 2
3 3
1 3
2 0
4 4
2 4
1 3
2 0
1 1
0 4
4 2
1 3
2 2
4 2
4 2
1 3
1 3
2 2
4 2
3 3
4 ...

result:

wrong answer you didn't find a solution but jury did (test case 44)

Subtask #3:

score: 0
Wrong Answer

Test #34:

score: 0
Wrong Answer
time: 168ms
memory: 4112kb

input:

100000
5
846784256447769304 457696478728961702 128469521648960690 597630796847754190 104256763714529164
5
658897822238868978 472135077337628566 399538027669313322 622703684108675696 425723088635325654
5
917704960887390986 140817562615382054 877934664521057998 782212806618666818 616380973421914538
8
...

output:

128469521648960690 104256763714529164
597630796847754190 457696478728961702
846784256447769304 527663637788357946
116363142681744927 687223947118063625
622703684108675696 425723088635325654
472135077337628566 399538027669313322
658897822238868978 435836552503470944
524213386372000675 547367187371169...

result:

wrong answer you didn't find a solution but jury did (test case 871)

Subtask #4:

score: 0
Wrong Answer

Test #46:

score: 52
Accepted
time: 219ms
memory: 22636kb

input:

100
211957
911918942087402387 344230223346742784 16289402153237664 528890583619159010 886281719684850237 865484734102017297 321851390502278959 754268375474197153 237414161302130571 135637002716682378 824412491959977735 162505521049217610 246319278060116103 666703181591704279 650875500699154233 96397...

output:

151185218593491131 617965644421394665
127889221798540436 384575431507442898
297763258678226226 974475912328144454
274899520450916877 256232326652991667
636119585503185340 265565923551954272
762097465301089645 268918475515313507
450842754527569806 515507970408201576
759734155104998001 483175362467885...

result:

ok correct (100 test cases)

Test #47:

score: 52
Accepted
time: 218ms
memory: 25056kb

input:

100
370255
32123537214468981 350412204946624705 402282150635760683 248912430361225231 814736352355688646 993128811372128790 305317864278631485 66833495387076887 496823364648202292 264249740623008900 93622460733892150 517687340999728245 175953208796215136 463180247813587246 70314179322549593 14399267...

output:

18939300425824371 564462365294933439
767833947299229059 291700832860378905
514287001455875131 466810535227119481
573926990354180049 78401258362214543
490548768341497306 326164124358197296
472763997188424336 529767390079803982
408356446349847301 501265693634114159
927876587499975832 45481106999198073...

result:

ok correct (100 test cases)

Test #48:

score: 52
Accepted
time: 253ms
memory: 24604kb

input:

100
118972
792375453970645873 576892825324240408 748164844574876655 32445009242823206 772953447561904131 633394009050854551 73696656498092749 870080114842373195 702953534252556424 528688137119642251 451634665273988550 195243066602861962 87567025505658553 138064336792733795 933007798725485674 3381824...

output:

779415206077382361 479074387902355893
768531133321566922 434120103959984204
46214918757723582 194010047729809848
60237660908385474 515879716808613470
601325618640775563 120112483243766715
856225266033723818 288058688858499472
360719050942271139 572141977446111645
276962918950403382 46643051419419139...

result:

ok correct (100 test cases)

Test #49:

score: 0
Wrong Answer
time: 158ms
memory: 3796kb

input:

100000
9
445759869974051228 776915644420529579 55748031156491160 547224621619359770 889968101069780792 938247829722065514 237508986668564632 706265918966029229 370065298249404353
3
760967737555474154 295101678372866180 641208729681524189
2
127843418996257285 904661771444761027
10
636895207833865394 ...

output:

938247829722065514 445759869974051228
706265918966029229 692003849848058371
776915644420529579 370065298249404353
699134884407043800 573490471334966966
889968101069780792 237508986668564632
55748031156491160 563738543869172712
547224621619359770 309743287512831936
636312677871005383 4284839545660958...

result:

wrong answer you didn't find a solution but jury did (test case 2733)