QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#523353 | #8907. Конференция | jiamengtong | 5 | 136ms | 21900kb | C++14 | 3.7kb | 2024-08-18 08:53:40 | 2024-08-18 08:53:42 |
Judging History
answer
#include<bits/stdc++.h>
#define M 100005
using namespace std;
int n, seq[M], fl[M], nn[M];
struct node{
int l, r, id;
}a[M];
bool cmp(node x, node y)
{
if(x.r != y.r) return x.r < y.r;
return x.l < y.l;
}
map<int, int> mp;
struct SGT{
int fl[M << 3], mk[M << 3];
void clear()
{
memset(fl, 0, sizeof(fl));
memset(mk, 0, sizeof(mk));
}
void push_down(int p)
{
if(mk[p])
{
fl[p << 1] = mk[p << 1] = fl[p << 1 | 1] = mk[p << 1 | 1] = 1;
mk[p] = 0;
}
}
void add(int l, int r, int ql, int qr, int p)
{
if(ql <= l && r <= qr)
{
mk[p] = 1;
fl[p] = 1;
return;
}
push_down(p);
int mid = (l + r) >> 1;
if(ql <= mid) add(l, mid, ql, qr, p << 1);
if(qr > mid) add(mid + 1, r, ql, qr, p << 1 | 1);
fl[p] = fl[p << 1] | fl[p << 1 | 1];
}
int query(int l, int r, int ql, int qr, int p)
{
// cout << l << " " << r << " " << ql << " " << qr << " " << p << " " << fl[p] << endl;
if(ql <= l && r <= qr) return fl[p];
int mid = (l + r) >> 1, ret = 0;
push_down(p);
if(ql <= mid) ret = query(l, mid, ql, qr, p << 1);
if(qr > mid) ret |= query(mid + 1, r, ql, qr, p << 1 | 1);
fl[p] = fl[p << 1] | fl[p << 1 | 1];
return ret;
}
}sgt;
bool cmp1(node x, node y)
{
return x.l < y.l;
}
void solve(int tc)
{
scanf("%d", &n);
nn[tc] = n;
mp.clear();
sgt.clear();
memset(fl, 0, sizeof(fl));
for(int i = 1; i <= n; i++) scanf("%d%d", &a[i].l, &a[i].r), mp[a[i].l], mp[a[i].r], a[i].id = i;
// if(nn[2] == 42 && tc == 10)
// {
// cout << n << endl;
// for(int i = 0; i <= n / 4; i += 4) printf("%d %d %d %d %d %d %d %d\n", a[i + 1].l, a[i + 1].r, a[i + 2].l, a[i + 2].r, a[i + 3].l, a[i + 3].r, a[i + 4].l, a[i + 4].r);
// puts("");
// exit(0);
// }
// if(nn[2] == 42) return;
int cnt = 0;
for(auto &t : mp) t.second = ++cnt;
for(int i = 1; i <= n; i++) a[i].l = mp[a[i].l], a[i].r = mp[a[i].r];
// for(int i = 1; i <= n; i++) cout << a[i].l << " " << a[i].r << " " << a[i].id << endl;
sort(a + 1, a + n + 1, cmp);
// for(int i = 1; i <= n; i++) cout << a[i].l << " " << a[i].r << " " << a[i].id << endl;
int tot = 0;
int mxr = 0;
for(int i = 1; i <= n; i++) if(mxr < a[i].l) seq[++tot] = i, mxr = a[i].r;
// cout << tot << endl;
int num = 0;
for(int i = 1; i <= tot / 2; i++) sgt.add(1, cnt, a[seq[i]].l, a[seq[i]].r, 1), fl[a[seq[i]].id] = 2;
// cout << 1 << endl;
for(int i = 1; i <= n; i++)
{
if(a[i].r <= mxr) fl[a[i].id] = 1, num++;
}
// cout << a[seq[1]].l << " " << a[seq[1]].r << endl;
// cout << num << endl;
if(num <= n / 2)
{
for(int i = 1; i <= n; i++)
{
if(fl[i] == 2) printf("%d ", i);
else if(fl[i] != 1)
{
if(num < n / 2) num++;
else printf("%d ", i);
}
// cout << fl[i] << " " << num << " " << i << endl;
}
puts("");
}
else
{
// sort(a + 1, a + n + 1, cmp1);
// tot = 0;
// int mil = 1e9;
// for(int i = 1; i <= n; i++) if(mil > a[i].r) seq[++tot] = i, mil = a[i].l;
sgt.clear();
memset(fl, 0, sizeof(fl));
num = 0;
for(int i = tot / 2 + 1; i <= tot; i++) sgt.add(1, cnt, a[seq[i]].l, a[seq[i]].r, 1), fl[a[seq[i]].id] = 2;
// cout << 1 << endl;
for(int i = 1; i <= n; i++)
{
if(!sgt.query(1, cnt, a[i].l, a[i].r, 1)) fl[a[i].id] = 1, num++;
}
// if(num > n / 2) cout << 1 / 0 << endl;
cnt = 0;
for(int i = n; i >= 1; i--)
{
if(fl[i] == 2) printf("%d ", i), cnt++;
else if(fl[i] != 1)
{
if(num < n / 2) num++;
else printf("%d ", i), cnt++;
}
}
// if(cnt < n / 2) cout << 1 / 0 << endl;
puts("");
}
}
int main()
{
int T;
scanf("%d", &T);
// T = 1;
// freopen("data.in", "r", stdin);
// freopen("ans.out", "w", stdout);
for(int i = 1; i <= T; i++) solve(i);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 3ms
memory: 11972kb
input:
1 4 823983109 859315505 510901709 589624124 351308325 413158126 29447781 138101981
output:
2 1
result:
ok answers are correct. (1 test case)
Test #2:
score: 5
Accepted
time: 0ms
memory: 11532kb
input:
1 10 344190293 385750493 951894838 978895800 82358344 338131819 540516504 607653166 820688970 951835774 395392706 419489159 623802732 644208366 798160348 818154082 680378878 682083538 467019518 519267671
output:
9 8 7 5 2
result:
ok answers are correct. (1 test case)
Test #3:
score: 5
Accepted
time: 0ms
memory: 12148kb
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:
497 496 493 491 488 487 481 480 477 476 473 470 469 465 464 461 460 458 454 453 452 451 446 443 442 441 440 439 437 435 434 431 430 427 426 425 421 420 419 417 415 414 413 409 408 406 405 400 399 397 391 389 388 386 385 384 382 380 376 374 373 372 367 366 365 364 362 361 359 357 349 348 346 345 342 ...
result:
ok answers are correct. (1 test case)
Test #4:
score: 5
Accepted
time: 0ms
memory: 12144kb
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:
998 995 994 992 989 987 985 983 981 979 976 975 974 973 971 970 969 968 965 963 962 961 959 956 954 951 948 947 946 943 942 941 940 938 933 932 931 930 929 928 927 926 925 923 922 921 920 918 915 913 911 910 908 906 905 904 902 901 899 896 895 894 892 891 888 884 882 881 880 879 878 876 873 871 870 ...
result:
ok answers are correct. (1 test case)
Test #5:
score: 5
Accepted
time: 7ms
memory: 12504kb
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:
9998 9997 9996 9991 9986 9983 9981 9979 9978 9977 9975 9974 9971 9970 9968 9967 9964 9963 9962 9961 9960 9955 9953 9950 9949 9946 9945 9943 9942 9937 9935 9934 9933 9932 9930 9927 9926 9924 9922 9920 9915 9914 9913 9912 9911 9906 9905 9904 9902 9900 9897 9895 9892 9891 9887 9886 9883 9882 9876 9875 ...
result:
ok answers are correct. (1 test case)
Test #6:
score: 5
Accepted
time: 12ms
memory: 13088kb
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:
9999 9997 9996 9994 9993 9984 9982 9974 9973 9972 9971 9969 9968 9967 9966 9965 9963 9961 9959 9958 9954 9953 9952 9950 9949 9948 9946 9945 9944 9943 9942 9941 9940 9939 9938 9937 9936 9934 9932 9931 9930 9929 9928 9927 9926 9925 9924 9922 9921 9920 9915 9914 9913 9911 9910 9909 9908 9907 9904 9903 ...
result:
ok answers are correct. (1 test case)
Test #7:
score: 5
Accepted
time: 136ms
memory: 21840kb
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:
99998 99996 99995 99991 99990 99985 99984 99981 99980 99978 99977 99976 99974 99973 99972 99970 99968 99967 99966 99965 99964 99963 99961 99960 99953 99952 99945 99944 99943 99942 99940 99938 99937 99934 99932 99931 99929 99927 99926 99925 99923 99922 99917 99916 99915 99914 99913 99911 99910 99908 ...
result:
ok answers are correct. (1 test case)
Test #8:
score: 5
Accepted
time: 130ms
memory: 21900kb
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:
100000 99999 99998 99997 99996 99993 99991 99988 99986 99984 99983 99981 99978 99977 99974 99969 99967 99966 99965 99963 99961 99960 99959 99958 99950 99949 99948 99945 99943 99942 99940 99939 99938 99937 99931 99928 99925 99924 99921 99920 99916 99915 99913 99912 99911 99909 99908 99899 99898 99895...
result:
ok answers are correct. (1 test case)
Subtask #2:
score: 0
Wrong Answer
Test #9:
score: 20
Accepted
time: 2ms
memory: 11548kb
input:
1 10 4 6 15 20 1 12 11 16 3 10 13 19 5 18 7 8 2 17 9 14
output:
10 5 4 3 2
result:
ok answers are correct. (1 test case)
Test #10:
score: 20
Accepted
time: 0ms
memory: 12048kb
input:
1 10 117956745 973823632 23571766 719701618 38785378 558526309 231187237 674007540 733362426 831144169 89816954 851213129 249341944 612792325 373425880 852493895 483542387 985564497 696597340 810358170
output:
1 5 6 8 9
result:
ok answers are correct. (1 test case)
Test #11:
score: 20
Accepted
time: 2ms
memory: 11380kb
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:
7 6 5 4 3 2 1
result:
ok answers are correct. (1 test case)
Test #12:
score: 20
Accepted
time: 0ms
memory: 12036kb
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:
14 13 8 6 4 3 2 1
result:
ok answers are correct. (1 test case)
Test #13:
score: 20
Accepted
time: 2ms
memory: 11564kb
input:
1 20 456674597 608693437 109249158 596412179 370495893 870389856 488084264 934790215 442774596 811747447 872496853 921725870 376801154 471157541 845813365 998784402 228965099 809754209 382052625 391934909 259367607 683974291 670301847 878762117 35222309 784937368 185199365 910293412 413659466 752376...
output:
12 9 8 7 6 5 4 3 2 1
result:
ok answers are correct. (1 test case)
Test #14:
score: 0
Wrong Answer
time: 0ms
memory: 11596kb
input:
1 20 297037250 419041198 282321805 321064650 349747242 362433069 351288380 375542434 419041198 445887196 602441780 958674622 241096289 375542434 475310449 592319891 349747242 913534896 383581240 419041198 173682409 328216346 328216346 603578694 472233867 801490971 95678652 168142402 168373452 387862...
output:
18 15 13 12 10 9 8 6 5 1
result:
wrong answer answer size for input: 6, answer size in participant solution: 4 (test case 1)
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #39:
score: 15
Accepted
time: 2ms
memory: 10884kb
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 6 4 3 2
result:
ok answers are correct. (1 test case)
Test #40:
score: 15
Accepted
time: 2ms
memory: 11772kb
input:
1 100 152 159 63 64 101 102 105 106 90 175 114 173 181 190 37 44 186 189 126 127 135 138 27 34 136 137 76 77 149 164 129 130 17 18 68 71 66 73 11 12 47 48 67 72 49 54 21 22 118 121 3 4 117 170 83 194 91 112 124 133 139 140 85 88 151 162 86 87 84 89 116 171 30 31 6 9 46 195 92 97 14 15 125 132 39 42 ...
output:
98 92 89 81 78 73 72 68 67 65 64 61 58 56 55 54 53 52 50 48 47 46 45 44 42 40 39 36 35 34 33 32 31 30 29 28 27 25 16 15 13 11 10 9 7 6 5 4 3 1
result:
ok answers are correct. (1 test case)
Test #41:
score: 15
Accepted
time: 0ms
memory: 11308kb
input:
1 100 192 193 83 84 38 39 33 34 120 121 19 20 118 119 175 176 13 14 74 75 154 155 101 102 68 69 146 147 81 82 89 90 53 54 190 191 181 182 48 49 139 140 40 41 72 73 116 117 1 200 124 125 4 145 9 50 150 151 112 113 27 28 122 123 5 126 46 47 152 153 29 30 91 92 25 26 188 189 110 111 104 105 11 12 179 1...
output:
100 97 96 95 94 92 91 90 87 85 83 79 78 77 76 74 71 68 65 64 63 61 59 56 54 53 51 48 47 43 40 39 35 33 32 30 29 27 26 25 24 21 19 18 14 11 8 7 5 1
result:
ok answers are correct. (1 test case)
Test #42:
score: 0
Wrong Answer
time: 0ms
memory: 11488kb
input:
1 100 189264773 692317517 166821159 730826701 132093661 747760156 244413340 258044743 425913239 571468467 345436794 608324228 414722760 580844232 4880692 979509087 381662564 593964118 15895639 957413704 17946557 939078604 73528693 867087267 18964638 919816261 39059497 884193691 278085494 635574530 2...
output:
45 46 47 48 49 50 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 97 98 99 100
result:
wrong answer answer size for input: 10, answer size in participant solution: 1 (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%