QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#523354 | #8907. Конференция | jiamengtong | 5 | 123ms | 21920kb | C++14 | 3.7kb | 2024-08-18 08:56:49 | 2024-08-18 08:56:50 |
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(!sgt.query(1, cnt, a[i].l, a[i].r, 1)) fl[a[i].id] = 1, num++;
}
// cout << a[seq[1]].l << " " << a[seq[1]].r << endl;
// cout << num << endl;
if(seq[tot / 2] >= 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;
}
详细
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 2ms
memory: 11776kb
input:
1 4 823983109 859315505 510901709 589624124 351308325 413158126 29447781 138101981
output:
3 4
result:
ok answers are correct. (1 test case)
Test #2:
score: 5
Accepted
time: 2ms
memory: 11332kb
input:
1 10 344190293 385750493 951894838 978895800 82358344 338131819 540516504 607653166 820688970 951835774 395392706 419489159 623802732 644208366 798160348 818154082 680378878 682083538 467019518 519267671
output:
1 3 4 6 10
result:
ok answers are correct. (1 test case)
Test #3:
score: 5
Accepted
time: 2ms
memory: 12108kb
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:
2 3 4 5 6 7 8 9 11 18 21 23 28 29 30 31 33 37 38 40 41 42 43 44 45 49 50 51 56 59 60 61 62 65 66 67 68 70 71 72 73 74 76 77 78 79 82 85 86 89 90 91 96 97 99 101 102 103 106 107 109 112 113 114 116 118 120 121 122 123 124 125 126 129 134 138 139 140 141 142 143 144 146 148 149 150 152 153 155 157 164...
result:
ok answers are correct. (1 test case)
Test #4:
score: 5
Accepted
time: 2ms
memory: 12464kb
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:
2 5 6 7 9 12 13 15 18 22 23 24 26 27 29 32 33 34 35 36 38 39 40 41 42 44 53 54 55 56 61 62 64 67 68 72 73 75 77 79 83 84 85 86 87 89 93 96 97 98 100 105 106 107 110 111 113 115 116 121 123 124 125 126 128 129 130 133 138 141 143 147 149 152 158 160 161 166 168 170 171 173 174 176 178 179 180 181 182...
result:
ok answers are correct. (1 test case)
Test #5:
score: 5
Accepted
time: 11ms
memory: 13172kb
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:
1 2 6 8 13 15 17 21 24 25 27 28 30 33 37 38 39 40 41 43 44 45 47 48 49 51 56 57 58 60 61 64 66 67 69 70 71 74 76 77 80 81 83 84 85 88 89 90 91 92 95 96 99 100 101 106 108 111 112 116 117 118 119 120 123 125 126 129 130 133 135 136 138 141 143 145 146 148 150 151 155 156 157 158 166 167 169 170 174 1...
result:
ok answers are correct. (1 test case)
Test #6:
score: 5
Accepted
time: 10ms
memory: 12116kb
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:
8 10 18 19 20 21 24 25 27 28 29 30 32 33 35 40 42 46 47 48 53 56 58 61 62 63 68 74 75 76 78 79 80 81 82 85 89 91 95 96 97 98 99 100 102 103 104 106 107 109 110 111 113 114 116 117 118 119 120 121 123 124 130 132 135 138 140 141 143 145 147 149 154 157 159 160 162 163 164 167 168 169 173 175 176 178 ...
result:
ok answers are correct. (1 test case)
Test #7:
score: 5
Accepted
time: 114ms
memory: 21920kb
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:
1 2 3 4 6 7 9 10 11 14 15 16 19 21 27 29 31 35 38 39 49 51 57 60 63 67 69 70 71 72 73 74 76 81 82 84 87 88 89 90 91 92 93 94 96 101 102 106 108 110 112 114 116 117 118 120 121 122 124 127 128 129 133 137 138 140 143 145 147 148 149 151 152 153 154 158 161 162 165 168 172 176 177 184 185 191 197 198 ...
result:
ok answers are correct. (1 test case)
Test #8:
score: 5
Accepted
time: 123ms
memory: 21528kb
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:
5 6 8 10 12 13 15 16 17 18 19 21 22 29 32 33 34 36 37 38 39 41 42 43 44 45 46 47 48 49 50 51 52 53 59 62 64 65 67 73 74 75 77 86 89 90 95 96 102 103 104 105 107 109 111 112 114 116 117 118 120 121 123 125 129 131 132 141 143 146 147 148 150 151 152 153 156 162 163 164 165 166 167 169 170 171 174 177...
result:
ok answers are correct. (1 test case)
Subtask #2:
score: 0
Wrong Answer
Test #9:
score: 20
Accepted
time: 0ms
memory: 11916kb
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: 0
Wrong Answer
time: 3ms
memory: 11644kb
input:
1 10 117956745 973823632 23571766 719701618 38785378 558526309 231187237 674007540 733362426 831144169 89816954 851213129 249341944 612792325 373425880 852493895 483542387 985564497 696597340 810358170
output:
10 6 5 2 1
result:
wrong answer answer size for input: 2, answer size in participant solution: 2 (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: 11940kb
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: 11060kb
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: 11324kb
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:
2 3 4 6 9 10 12 13 15 16 17 20 22 23 31 34 36 37 38 41 42 44 45 49 50 52 54 55 57 58 60 62 66 67 69 70 72 73 75 80 81 82 83 84 86 88 89 93 98 99
result:
ok answers are correct. (1 test case)
Test #42:
score: 15
Accepted
time: 0ms
memory: 11284kb
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:
96 95 55 54 53 52 50 49 48 47 46 45 44 42 41 39 37 35 34 33 32 31 30 29 28 27 26 25 24 23 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 3 2 1
result:
ok answers are correct. (1 test case)
Test #43:
score: 15
Accepted
time: 2ms
memory: 11596kb
input:
1 100 327645749 329093539 980227412 994005154 579806213 598354521 898396499 898525148 545535670 547099732 57665434 63966759 91822376 112410483 898974428 932154782 174406471 268197958 272306427 273971634 389680998 390221315 3154994 997314160 269858259 282937852 343400516 407809409 620512844 631492929...
output:
99 97 95 89 88 86 83 82 81 80 78 77 76 74 72 71 70 69 67 65 63 61 59 58 57 53 49 47 46 42 41 40 39 36 33 32 29 25 24 23 22 18 17 15 12 8 5 4 3 2
result:
ok answers are correct. (1 test case)
Test #44:
score: 15
Accepted
time: 0ms
memory: 11564kb
input:
1 100 19022424 295717821 521909470 631285980 497332842 642316879 652870043 654095607 1416391 996731107 325050618 333648846 854687185 897107660 53041861 61991654 182273029 231298999 38904128 236257569 307694478 357691523 579993158 583091697 239954119 244805531 434287435 485536294 225429937 226370246 ...
output:
6 13 15 20 22 24 25 26 27 29 31 32 33 36 37 39 41 42 43 45 48 51 52 53 55 57 58 60 61 62 65 66 67 68 69 70 71 72 73 74 76 77 80 82 87 88 93 97 98 99
result:
ok answers are correct. (1 test case)
Test #45:
score: 15
Accepted
time: 2ms
memory: 11476kb
input:
1 500 689426082 689507542 427389970 430516694 305033996 305649163 125494668 126279290 235974559 238575143 113585036 123617477 809213065 811464735 695392709 697437354 44577991 45927754 356984995 358581387 853780607 858598288 494073918 494101939 531949799 532852851 910230931 912010323 496284517 500744...
output:
500 495 492 491 489 488 484 483 482 481 478 475 474 468 466 465 462 458 457 456 455 453 451 447 443 441 440 438 436 434 430 424 422 419 418 417 414 412 409 407 406 404 403 400 392 391 390 388 384 383 381 380 379 374 373 372 370 368 367 366 365 364 363 361 360 359 358 357 346 345 344 342 340 339 338 ...
result:
ok answers are correct. (1 test case)
Test #46:
score: 15
Accepted
time: 0ms
memory: 12160kb
input:
1 500 298167304 298463628 791031018 794720207 659273641 659882121 104798428 105261813 211419472 211890862 743609251 750342623 785451379 825218182 161739521 165868601 668366592 670883708 17846664 980939732 623757216 629418838 57011271 280805195 702352076 702445129 242115912 248568730 392104305 412710...
output:
4 5 14 23 24 26 28 40 46 48 59 64 74 75 80 90 92 94 95 101 104 105 106 109 114 117 118 119 120 121 122 124 125 126 130 131 132 133 134 135 137 139 140 142 145 147 148 150 151 152 153 154 155 165 166 167 169 170 171 172 174 175 176 177 178 179 180 182 184 185 186 187 189 193 194 196 198 199 203 204 2...
result:
ok answers are correct. (1 test case)
Test #47:
score: 0
Wrong Answer
time: 3ms
memory: 11088kb
input:
10 60 11164929 994881562 299556408 474028014 66299485 119766199 432871164 460158656 132161383 176718496 271951527 606038754 539359133 553976140 949470174 958412706 661828987 994881562 12788677 49941342 891211584 895712102 724455378 983161900 152648130 160372649 225338436 227986635 949470174 97419152...
output:
59 57 55 53 52 50 45 43 39 36 34 33 32 31 30 29 27 26 23 21 20 16 15 12 11 9 8 7 6 1 13 11 10 7 6 5 3 2 4 1 100 88 85 84 82 80 78 74 73 72 71 70 68 67 66 65 64 63 62 61 59 58 57 51 48 45 44 43 42 40 39 38 36 32 31 30 28 24 23 22 21 19 18 13 11 10 9 7 6 4 105 104 103 102 101 100 95 94 93 90 87 86...
result:
wrong answer Integer parameter [name=/opt/uoj/judger/uoj_judger/work/47.ans_14] equals to 41, violates the range [1, 28] (test case 6)
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%