QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#569913 | #9310. Permutation Counting 4 | qwqqwqqwqqwqssss | TL | 322ms | 58684kb | C++14 | 1.4kb | 2024-09-17 12:09:40 | 2024-09-17 12:22:34 |
Judging History
answer
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define rep(Ii,Jj,Kk) for(int Ii=(Jj),Ii##_=(Kk);Ii<=Ii##_;Ii++)
#define per(Ii,Jj,Kk) for(int Ii=(Jj),Ii##_=(Kk);Ii>=Ii##_;Ii--)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double db;
#define fir first
#define sec second
#define siz(Aa) ((int)(Aa).size())
#define all(Aa) (Aa).begin(),(Aa).end()
#define ckmx(Aa,Bb) (Aa=max(Aa,Bb))
#define ckmn(Aa,Bb) (Aa=min(Aa,Bb))
void eachT();
signed main(){ios::sync_with_stdio(false),cin.tie(nullptr);
int T;cin>>T;
while(T--)eachT();
return 0;}
/*
*/
void eachT() {
int n;
cin >> n;
vector<vector<int>> v(n + 2);
for (int i = 0; i < n; ++i) {
int l, r;
cin >> l >> r;
v[l].push_back(r);
}
bool ok = 1;
// int cnt=0;
for (int l = 1; l <= n; ++l) {
if (v[l].empty()) {
ok = 0;
break;
}
sort(v[l].begin(), v[l].end(), greater<>());
int big = v[l][0];
for (int j = 1; j < v[l].size(); ++j) {
if (v[l][j - 1] == v[l][j]) {
ok = 0;
break;
}
int r = v[l][j];
v[r + 1].push_back(big);
// cnt++;
}
if (ok == 0) break;
}
cout << ok << '\n';
// cerr<<cnt<<endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3748kb
input:
4 5 1 2 1 5 1 2 1 2 2 2 5 1 1 2 4 2 3 5 5 3 4 5 3 5 1 2 3 4 3 5 3 3 5 1 5 1 4 4 5 5 5 1 2
output:
0 1 0 0
result:
ok 4 tokens
Test #2:
score: 0
Accepted
time: 116ms
memory: 3828kb
input:
66725 14 7 7 4 6 7 8 8 13 2 13 6 13 6 10 14 14 1 10 9 11 7 9 3 8 4 12 5 12 12 2 6 3 6 7 11 2 5 1 1 6 12 8 12 2 3 7 9 7 8 1 10 1 4 10 4 8 4 4 6 10 9 10 2 3 2 7 1 3 3 4 2 2 3 10 20 3 12 10 14 19 20 19 20 1 9 7 9 13 16 17 17 16 18 2 11 5 19 6 17 11 17 3 6 3 11 7 20 8 17 3 18 10 15 9 20 16 5 10 2 10 2 1...
output:
1 1 0 0 1 0 1 1 0 1 1 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 1 0 0 0 0 1 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 0 1 1 0 0 0 0 0 0 1 0 1 1 0 1 1 1 0 1 0 1 0 0 0 1 1 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 1 1 0 0 1 1 1 0 0 1 1 0 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 1 0 0 1 0 1 1 ...
result:
ok 66725 tokens
Test #3:
score: 0
Accepted
time: 129ms
memory: 3552kb
input:
6655 155 28 58 68 100 6 47 98 109 11 133 38 153 73 118 126 153 24 43 71 118 109 135 6 104 40 101 24 139 100 136 135 136 40 148 70 117 92 124 63 64 45 55 16 128 65 86 20 49 126 138 30 141 127 146 21 155 49 139 27 34 39 145 20 53 12 41 3 107 38 78 106 109 61 102 20 99 134 135 23 99 10 69 105 113 36 75...
output:
0 0 1 1 0 1 0 0 1 1 0 1 1 1 0 0 1 1 1 0 1 0 1 0 1 0 0 1 1 0 1 0 0 0 1 1 0 1 0 1 0 1 0 1 1 1 1 0 1 0 0 0 0 0 1 1 0 1 0 1 0 1 0 1 0 0 1 0 0 1 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 1 0 0 0 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 1 0 0 0 0 ...
result:
ok 6655 tokens
Test #4:
score: 0
Accepted
time: 140ms
memory: 3708kb
input:
666 1967 396 1664 818 1954 564 805 1106 1322 568 1687 853 1482 153 1092 566 670 154 562 114 1372 574 1879 482 1083 499 1566 2 1384 291 1947 122 1714 1277 1900 740 1024 887 1478 146 254 944 1807 574 1193 225 1933 43 1278 1017 1482 958 1180 86 1230 1658 1679 980 1542 1044 1127 762 989 1128 1567 552 17...
output:
0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1 0 1 0 0 0 0 1 1 0 0 1 0 1 1 0 1 0 0 1 1 1 1 1 0 1 1 1 0 0 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 1 1 1 1 0 1 1 0 1 0 0 1 1 1 1 1 0 0 1 1 0 0 1 0 0 1 0 1 1 0 1 1 1 1 1 1 0 0 0 0 1 1 0 ...
result:
ok 666 tokens
Test #5:
score: 0
Accepted
time: 147ms
memory: 5324kb
input:
67 12220 945 3456 3457 11698 945 3023 945 10249 945 6035 3457 12211 3024 9082 6554 10249 3179 11698 945 2449 3457 6897 945 3625 4115 9082 3626 11593 2450 3525 3526 5410 3179 5606 5607 8510 5607 8159 1908 9082 6898 9270 3457 4922 6669 9082 2936 10249 2936 9009 1796 5410 4923 10474 2450 5488 3526 6232...
output:
1 1 0 1 1 1 0 0 0 1 0 0 0 0 1 1 1 1 1 0 0 0 0 1 1 0 0 1 0 0 1 0 1 1 0 1 1 0 0 1 1 0 1 1 0 0 0 0 1 0 1 1 0 1 1 1 0 1 1 0 0 1 1 1 1 0 1
result:
ok 67 tokens
Test #6:
score: 0
Accepted
time: 169ms
memory: 15432kb
input:
6 189286 20378 70057 112636 186453 18829 100288 79275 115176 63489 100397 91394 117835 82935 156201 139293 142914 73817 98058 45394 109570 29456 122157 137106 187436 155188 173045 78214 89538 128432 165866 151755 155927 10312 86728 127548 136028 27985 151840 67594 139392 116691 134229 83762 102392 2...
output:
0 0 1 1 1 0
result:
ok 6 tokens
Test #7:
score: 0
Accepted
time: 322ms
memory: 58684kb
input:
1 1000000 94615 809894 94615 262270 762901 809894 762901 765167 94615 555380 94615 515529 473424 762900 262271 698085 36290 809894 294342 809894 473424 706007 94615 725798 725799 966460 602080 966460 51014 762900 338866 473423 93158 338865 28544 698085 416220 966460 6640 555380 215959 698085 253649 ...
output:
1
result:
ok "1"
Test #8:
score: 0
Accepted
time: 221ms
memory: 44332kb
input:
1 1000000 25927 931541 549663 947731 435323 484750 320537 420368 154427 330335 204649 698863 119951 619271 299655 485176 266828 632738 621134 818227 529143 683026 134580 498562 513579 586797 184440 719755 258499 785336 546208 853976 407308 494237 176985 846562 79646 969633 297019 505247 65287 287869...
output:
0
result:
ok "0"
Test #9:
score: 0
Accepted
time: 235ms
memory: 44568kb
input:
1 1000000 708148 839950 121329 290905 510828 569312 437062 892947 18749 896294 40631 125586 207243 247889 51468 93552 440810 694824 29877 145371 453173 456834 215578 649145 278488 353906 492636 676255 590863 913302 23982 765827 558855 973649 259253 402361 415102 552772 283526 306361 586620 693138 27...
output:
0
result:
ok "0"
Test #10:
score: 0
Accepted
time: 306ms
memory: 58628kb
input:
1 1000000 282918 797950 797951 915225 615399 915225 457486 615398 321702 797950 414142 797950 86620 414141 86620 388932 86620 998765 440839 457485 86620 448168 99138 998765 414142 494939 333492 448168 99138 597241 895799 915225 111714 615398 414142 906877 80369 321701 797951 979896 457486 535578 333...
output:
1
result:
ok "1"
Test #11:
score: 0
Accepted
time: 214ms
memory: 44336kb
input:
1 1000000 831328 870733 206720 363737 918611 979445 89822 488412 396737 611744 354139 765908 486638 518418 296801 990821 187722 808282 80742 649459 738441 819473 242541 441310 158310 764373 110901 879938 204155 274087 119096 414236 296080 877904 523676 628788 492136 579838 599930 731872 14581 265820...
output:
0
result:
ok "0"
Test #12:
score: 0
Accepted
time: 280ms
memory: 58608kb
input:
1 1000000 250412 737666 737667 993185 861375 993185 721908 993185 209954 721907 737667 789700 435283 737666 164916 209953 149936 861374 209954 559650 69081 250411 298411 721907 173631 861374 57828 298410 435283 892327 863076 892327 283363 298410 3290 721907 789701 949793 559651 985187 3290 755642 32...
output:
1
result:
ok "1"
Test #13:
score: 0
Accepted
time: 203ms
memory: 44692kb
input:
1 1000000 318973 779919 438410 978223 455585 723466 308013 977990 263871 538496 86744 501121 72052 419373 15911 268439 499883 527765 679230 868802 330840 803740 380942 392943 65937 674331 288146 672318 694032 909594 213386 345973 452124 929529 262584 931207 24900 750763 254895 600549 851295 950130 1...
output:
0
result:
ok "0"
Test #14:
score: 0
Accepted
time: 194ms
memory: 44568kb
input:
1 1000000 239440 968541 377517 869195 530856 816462 232729 422351 11399 612034 430469 766063 401926 402352 522675 872089 478392 926439 146525 555357 543387 701528 402678 760896 712375 818266 21282 619683 352812 426092 289076 482125 874816 973856 53811 333775 218802 267228 65809 292143 676521 982871 ...
output:
0
result:
ok "0"
Test #15:
score: 0
Accepted
time: 193ms
memory: 44668kb
input:
1 1000000 499131 501875 7544 495774 133830 316225 13323 142112 218559 877222 137527 418509 138614 248102 84060 395886 345499 494655 166777 315709 373952 878560 734659 950965 38749 967905 699108 701549 135426 572760 136007 898008 666899 950808 547838 553056 702428 943307 386478 629552 564870 694439 6...
output:
0
result:
ok "0"
Test #16:
score: 0
Accepted
time: 203ms
memory: 44352kb
input:
1 1000000 20752 494590 443015 633649 748804 831912 498508 583322 25172 224797 198063 709209 265567 760531 169111 263603 88340 150378 683819 685360 816602 953394 3949 336072 512193 890817 198122 812621 30617 612527 721756 877615 291877 727436 540881 917775 131459 714576 413668 542545 142171 778729 37...
output:
0
result:
ok "0"
Extra Test:
score: -3
Extra Test Failed : Time Limit Exceeded on 2
input:
1 1000000 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60...