QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#488576#8907. КонференцияPorNPtree5 27ms7032kbC++171.8kb2024-07-24 11:06:392024-07-24 11:06:41

Judging History

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

  • [2024-07-24 11:06:41]
  • 评测
  • 测评结果:5
  • 用时:27ms
  • 内存:7032kb
  • [2024-07-24 11:06:39]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int L[N], R[N];

struct seg {
    int l, r, id;
} p[N];

int cmp1(seg x, seg y) {
    return x.r < y.r;
}

int cmp2(seg x, seg y) {
    return x.l > y.l;
}

int vis[N];

signed main() {
    int T; scanf("%d", &T);
    while (T--) {
        int n; scanf("%d", &n);
        for (int i = 1; i <= n; ++i) {
            scanf("%d%d", &p[i].l, &p[i].r), p[i].id = i, vis[i] = 0;
            L[i] = p[i].l, R[i] = p[i].r;
        }
        vector<int> id1, id2;
        sort(p + 1, p + n + 1, cmp1);
        for (int i = 1, mx = 0; i <= n; ++i) {
            if (p[i].l > mx) id1.push_back(p[i].id), mx = p[i].r;
        }
        sort(p + 1, p + n + 1, cmp2);
        for (int i = 1, mn = 1e9 + 1; i <= n; ++i) {
            if (p[i].r < mn) id2.push_back(p[i].id), mn = p[i].l;
        }
        vector<int> p1, p2, p3, p4;
        for (int i = 0; i < (int)id1.size(); ++i) {
            if (i < id1.size() >> 1) p1.push_back(id1[i]);
        }
        for (int i = 0; i < (int)id2.size(); ++i) {
            if (i < id2.size() >> 1) p2.push_back(id2[i]);
        }
        for (auto x : p1) vis[x] = 1;
        for (auto x : p2) vis[x] = 1;
        for (int i = 1; i <= n; ++i) if (!vis[i]) {
            int flg = 0;
            for (auto x : p1) {
                flg |= (L[i] <= R[x] && L[x] <= R[i]);
                if (!flg) break;
            }
            if (flg) p3.push_back(i);
            else p4.push_back(i);
        }
        p1.insert(p1.end(), p3.begin(), p3.end());
        p2.insert(p2.end(), p4.begin(), p4.end());
        if (p1.size() < p2.size()) swap(p1, p2);
        for (int i = 0; i < (n >> 1); ++i) printf("%d%c", p1[i], " \n"[i + 1 == (n >> 1)]);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 0ms
memory: 4128kb

input:

1
4
823983109 859315505
510901709 589624124
351308325 413158126
29447781 138101981

output:

4 3

result:

ok answers are correct. (1 test case)

Test #2:

score: 5
Accepted
time: 1ms
memory: 5868kb

input:

1
10
344190293 385750493
951894838 978895800
82358344 338131819
540516504 607653166
820688970 951835774
395392706 419489159
623802732 644208366
798160348 818154082
680378878 682083538
467019518 519267671

output:

3 1 6 10 4

result:

ok answers are correct. (1 test case)

Test #3:

score: 5
Accepted
time: 0ms
memory: 5880kb

input:

1
500
943625790 945741848
367933677 368747115
117030592 118328257
321658393 322265356
413440931 413466704
191801051 192382494
45318188 45578563
184352813 184557169
267846012 270194842
787080743 789209469
102034755 102793278
677264139 679983858
858429750 858446103
879077624 879224701
573990877 574468...

output:

323 478 486 483 456 418 368 126 72 212 498 499 30 449 233 358 462 66 337 138 68 252 308 7 422 107 205 140 402 203 152 258 429 433 61 326 407 305 190 181 202 284 200 270 306 37 455 378 42 144 134 120 412 113 293 11 343 141 146 230 122 3 354 82 495 71 97 28 467 475 355 403 447 423 436 102 86 91 444 36...

result:

ok answers are correct. (1 test case)

Test #4:

score: 5
Accepted
time: 1ms
memory: 3860kb

input:

1
1000
724221604 725069540
143194275 144876990
944969667 945425601
692430254 692500244
413915365 415513016
441154319 441817251
397426964 397797495
573976568 574310166
333482080 333658815
692670858 693494033
781215754 781315542
297042073 297766151
347972954 348085089
567271813 567539623
43283944 4381...

output:

536 529 141 334 820 451 945 454 354 850 897 197 126 949 602 534 393 282 196 646 413 284 703 272 39 710 96 396 125 952 173 130 367 265 903 121 692 810 349 320 23 219 641 411 15 844 269 75 550 661 242 777 698 621 129 616 189 955 105 276 957 887 539 221 336 705 937 991 55 759 174 373 631 475 742 41 220...

result:

ok answers are correct. (1 test case)

Test #5:

score: 5
Accepted
time: 3ms
memory: 4164kb

input:

1
10000
1915 1916
6871 6872
12925 12926
12679 12680
18809 18810
4725 4726
12781 12782
6363 6364
18471 18472
17037 17038
13225 13226
12201 12202
8365 8366
11427 11428
2859 2860
18423 18424
3519 3520
14647 14648
17649 17650
11249 11250
9003 9004
15623 15624
11345 11346
457 458
4805 4806
17905 17906
84...

output:

4766 9608 8588 7970 4330 9042 4619 4019 1723 757 970 9509 337 91 3766 4462 9793 9109 860 5577 5179 195 7485 8534 3584 2915 4590 8995 4070 9081 1263 3916 4154 8800 8845 431 7355 6314 862 8463 3690 8332 4622 3145 2320 711 1148 3671 8729 5355 2896 2144 6869 6707 9908 1781 4853 6186 8683 4740 1049 607 3...

result:

ok answers are correct. (1 test case)

Test #6:

score: 5
Accepted
time: 3ms
memory: 4140kb

input:

1
10000
951623572 951627967
944693469 944698949
866936571 866953676
708414261 708441197
918925455 918994693
693014496 693052258
500076831 500117857
346961903 346994890
790230509 790247658
486707346 486907093
703108219 703186545
666115252 666249778
638756819 638771288
605550898 605661894
618156528 61...

output:

1837 2807 1955 6579 7554 6281 5488 969 3590 9148 6570 8567 280 2499 4882 8400 1338 6559 427 3961 5378 6589 4656 7420 197 3758 6452 3502 2556 8342 4209 3498 5293 6217 861 8639 7676 4264 3927 6756 1509 7028 7189 2333 6530 8154 6671 1528 7229 1723 1488 4628 8086 7560 7277 7793 7580 9558 9145 1051 2238 ...

result:

ok answers are correct. (1 test case)

Test #7:

score: 5
Accepted
time: 27ms
memory: 6952kb

input:

1
100000
95477550 95482342
57260360 57270968
324158435 324161602
337960344 337966333
843677712 843688311
61482892 61483547
494172231 494182559
843751785 843754290
158705730 158714372
136974660 136976009
424424906 424425379
802041471 802042132
670649961 670659516
155724598 155724784
245837370 2458388...

output:

71939 99928 86010 22766 47721 66161 24469 20566 99568 6269 93234 45127 5007 29782 9053 25180 12136 64304 84962 81419 66887 58844 76589 34741 133 84150 2327 14810 67578 84023 79006 36899 55583 62141 9538 53071 15503 29124 31836 36145 98044 62689 45609 96058 71646 96895 75087 46761 79850 89193 98612 9...

result:

ok answers are correct. (1 test case)

Test #8:

score: 5
Accepted
time: 25ms
memory: 7032kb

input:

1
100000
126151 126152
147685 147686
168691 168692
124505 124506
58489 58490
98015 98016
173339 173340
39469 39470
135733 135734
53105 53106
118229 118230
46503 46504
36953 36954
185819 185820
27699 27700
64063 64064
60847 60848
18307 18308
1697 1698
109113 109114
99305 99306
72117 72118
107975 1079...

output:

75377 51260 37869 20294 14965 95874 5667 11492 31580 717 17389 44033 71923 88665 87417 92824 48939 36551 94330 82375 3013 5157 98708 5429 56464 64915 79502 42666 95763 19728 57214 90790 52810 50976 8996 33863 42096 24445 92194 61911 74140 40171 77799 94597 63531 25724 59373 39922 1130 73597 70370 28...

result:

ok answers are correct. (1 test case)

Subtask #2:

score: 0
Wrong Answer

Test #9:

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

input:

1
10
4 6
15 20
1 12
11 16
3 10
13 19
5 18
7 8
2 17
9 14

output:

1 8 3 5 7

result:

ok answers are correct. (1 test case)

Test #10:

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

input:

1
10
117956745 973823632
23571766 719701618
38785378 558526309
231187237 674007540
733362426 831144169
89816954 851213129
249341944 612792325
373425880 852493895
483542387 985564497
696597340 810358170

output:

3 1 2 4 6

result:

ok answers are correct. (1 test case)

Test #11:

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

input:

1
14
16686983 932034450
223405271 642058261
317002236 708563919
199994594 587702670
454769448 522126055
746578284 809511289
133298121 894605432
94273255 452589074
5923134 643331337
350619519 385885046
317742836 915325929
320415015 743405145
48507375 963122902
124278107 221614208

output:

14 10 1 4 7 8 9

result:

ok answers are correct. (1 test case)

Test #12:

score: 0
Wrong Answer
time: 0ms
memory: 4132kb

input:

1
16
100212181 610959822
59569481 946341427
168724782 490902631
156501761 504380971
25798133 52287573
318331091 915496014
208509217 366012539
288068792 715557962
256907803 526058782
50050253 126428948
104145448 301925232
146518183 863900618
639034909 804627990
412452373 490792746
108316345 249279177...

output:

13 14 1 2 3 4 6 7

result:

wrong answer answer size for input: 4, answer size in participant solution: 3 (test case 1)

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #39:

score: 0
Wrong Answer
time: 0ms
memory: 3908kb

input:

1
10
8 9
15 18
12 13
5 14
7 10
1 20
2 19
6 11
3 4
16 17

output:

10 3 2 4 5

result:

wrong answer answer size for input: 4, answer size in participant solution: 3 (test case 1)

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #2:

0%

Subtask #7:

score: 0
Skipped

Dependency #2:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%