ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#202985 | #2991. 上升序列 | snow_trace | 100 | 3150ms | 227940kb | C++11 | 1.2kb | 2024-02-18 10:28:14 | 2024-02-18 13:23:28 |
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define lowbit(x) x&(-x)
int n;
int tree[2000005],p[2000005],ans,cnt = 1;
vector<int>res[2000005],pp[2000005];
void upd(int pos,int add){
for(int i = pos;i<=n;i+=lowbit(i)){
if(i == pos)tree[i] = add;tree[i] = max(tree[i],add);
}
}int query(int x){
int res = 0;
for(int i = x;i;i-=lowbit(i))res = max(res,tree[i]);
return res;
}void dfs(int k,int d,int id){
if(d == ans){
cnt++;return;
}for(int i = pp[d+1].size()-1;i>=0;i--){
if(p[k]>p[pp[d+1][i]]){
pp[d+1].pop_back();continue;
}if(!pp[d+1].size() or k>pp[d+1][i]){
res[cnt].pop_back();return;
}int e = pp[d+1][i];
res[cnt].push_back(pp[d+1][i]);pp[d+1].pop_back();
dfs(e,d+1,cnt);if(cnt!=id)return;
}
}
signed main(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;for(int i = 1;i<=n;i++)cin>>p[i];
for(int i = 1;i<=n;i++){
int d = query(p[i])+1;pp[d].push_back(i);upd(p[i],d);ans = max(ans,d);
}for(int i = pp[1].size()-1;i>=0;i--){
int aa = pp[1][i];
res[cnt].push_back(aa);pp[1].pop_back();
dfs(aa,1,cnt);
}cnt--;
cout<<cnt<< ' '<<ans<< endl;
for(int i = 1;i<=cnt;i++){
for(int j =0;j<res[i].size();j++)cout<<res[i][j]<<' ';cout <<'\n';
}
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 15ms
memory: 95024kb
input:
7 6 2 7 4 1 5 3
output:
1 3 2 4 6
result:
ok ok
Test #2:
score: 0
Accepted
time: 19ms
memory: 95020kb
input:
7 3 1 5 7 2 6 4
output:
2 3 2 5 7 1 3 6
result:
ok ok
Test #3:
score: 0
Accepted
time: 8ms
memory: 95024kb
input:
9 6 5 3 7 8 2 4 1 9
output:
1 4 3 4 5 9
result:
ok ok
Test #4:
score: 0
Accepted
time: 20ms
memory: 95020kb
input:
15 15 12 11 14 8 10 9 5 6 7 2 3 13 1 4
output:
1 4 8 9 10 13
result:
ok ok
Test #5:
score: 0
Accepted
time: 20ms
memory: 95020kb
input:
4 2 1 3 4
output:
1 3 2 3 4
result:
ok ok
Test #6:
score: 0
Accepted
time: 11ms
memory: 95020kb
input:
15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
output:
1 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
result:
ok ok
Test #7:
score: 0
Accepted
time: 11ms
memory: 95016kb
input:
15 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
output:
15 1 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
result:
ok ok
Test #8:
score: 0
Accepted
time: 16ms
memory: 95020kb
input:
9 7 8 9 4 5 6 1 2 3
output:
3 3 7 8 9 4 5 6 1 2 3
result:
ok ok
Test #9:
score: 0
Accepted
time: 12ms
memory: 95020kb
input:
9 7 4 1 8 5 2 9 6 3
output:
3 3 3 6 9 2 5 8 1 4 7
result:
ok ok
Test #10:
score: 0
Accepted
time: 22ms
memory: 95020kb
input:
15 11 10 14 13 12 9 8 7 6 4 3 15 5 2 1
output:
1 3 2 5 12
result:
ok ok
Test #11:
score: 0
Accepted
time: 23ms
memory: 95020kb
input:
15 9 6 5 4 13 12 15 14 11 10 3 2 1 8 7
output:
2 3 4 6 8 3 5 7
result:
ok ok
Test #12:
score: 0
Accepted
time: 21ms
memory: 95024kb
input:
15 11 9 6 13 12 5 15 14 10 3 7 2 1 8 4
output:
3 3 10 11 14 3 5 8 2 4 7
result:
ok ok
Test #13:
score: 0
Accepted
time: 20ms
memory: 95024kb
input:
15 8 7 12 14 11 5 10 9 3 6 15 2 13 4 1
output:
1 4 2 3 4 11
result:
ok ok
Test #14:
score: 0
Accepted
time: 16ms
memory: 95024kb
input:
15 7 9 3 12 15 14 13 1 11 10 2 8 6 4 5
output:
2 4 8 11 14 15 1 2 4 7
result:
ok ok
Test #15:
score: 0
Accepted
time: 18ms
memory: 95016kb
input:
15 10 12 14 13 15 11 8 6 7 4 9 1 5 3 2
output:
1 4 1 2 4 5
result:
ok ok
Test #16:
score: 0
Accepted
time: 11ms
memory: 95024kb
input:
7 3 1 5 7 2 6 4
output:
2 3 2 5 7 1 3 6
result:
ok ok
Test #17:
score: 0
Accepted
time: 19ms
memory: 95024kb
input:
14 9 12 8 3 5 4 13 1 14 10 6 2 11 7
output:
2 4 4 6 11 14 1 2 7 9
result:
ok ok
Test #18:
score: 0
Accepted
time: 25ms
memory: 95020kb
input:
7 4 2 6 1 3 7 5
output:
2 3 4 5 7 2 3 6
result:
ok ok
Test #19:
score: 0
Accepted
time: 20ms
memory: 95020kb
input:
14 8 4 13 9 5 1 14 2 11 10 12 7 3 6
output:
2 4 6 8 13 14 2 5 10 11
result:
ok ok
Test #20:
score: 0
Accepted
time: 20ms
memory: 95004kb
input:
1 1
output:
1 1 1
result:
ok ok
Test #21:
score: 0
Accepted
time: 27ms
memory: 95020kb
input:
2 1 2
output:
1 2 1 2
result:
ok ok
Test #22:
score: 0
Accepted
time: 20ms
memory: 95016kb
input:
2 2 1
output:
2 1 2 1
result:
ok ok
Test #23:
score: 0
Accepted
time: 28ms
memory: 95016kb
input:
3 2 1 3
output:
1 2 2 3
result:
ok ok
Subtask #2:
score: 40
Accepted
Test #24:
score: 40
Accepted
time: 20ms
memory: 95028kb
input:
418 197 204 176 406 267 393 331 39 102 414 296 236 289 334 45 318 115 285 134 143 181 301 308 357 36...
output:
1 35 8 15 37 43 50 55 94 125 127 128 131 142 143 144 154 161 175 176 215 218 221 232 238 251 258 274...
result:
ok ok
Test #25:
score: 0
Accepted
time: 15ms
memory: 95032kb
input:
436 324 407 253 377 302 316 135 270 103 379 60 78 388 313 345 12 309 35 84 45 311 127 210 256 261 23...
output:
1 38 16 18 20 31 33 35 51 52 55 92 96 103 135 139 172 195 205 217 218 221 234 266 273 278 283 287 30...
result:
ok ok
Test #26:
score: 0
Accepted
time: 29ms
memory: 95036kb
input:
551 474 78 489 144 10 436 104 100 374 234 151 239 544 439 536 159 373 88 279 213 485 517 85 288 395 ...
output:
1 42 5 23 26 27 78 80 96 110 111 132 140 146 151 166 198 202 207 236 244 251 279 287 301 304 305 316...
result:
ok ok
Test #27:
score: 0
Accepted
time: 19ms
memory: 95044kb
input:
968 694 273 544 160 260 350 138 358 503 803 422 527 20 852 206 715 808 629 564 635 477 403 301 1 431...
output:
1 56 24 27 36 49 56 60 127 133 144 152 157 158 163 181 184 215 249 256 258 290 306 332 395 436 456 4...
result:
ok ok
Test #28:
score: 0
Accepted
time: 27ms
memory: 95032kb
input:
222 89 69 179 195 135 58 176 141 53 107 198 205 131 162 22 15 49 169 163 148 183 182 39 37 126 29 15...
output:
1 24 37 41 64 72 88 97 99 104 115 117 118 123 131 145 148 150 152 166 180 185 187 199 206 216
result:
ok ok
Test #29:
score: 0
Accepted
time: 19ms
memory: 95156kb
input:
1000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35...
output:
1 1000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 ...
result:
ok ok
Test #30:
score: 0
Accepted
time: 16ms
memory: 95068kb
input:
1000 1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 97...
output:
1000 1 1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 98...
result:
ok ok
Test #31:
score: 0
Accepted
time: 16ms
memory: 95048kb
input:
961 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 ...
output:
31 31 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 95...
result:
ok ok
Test #32:
score: 0
Accepted
time: 28ms
memory: 95048kb
input:
961 931 900 869 838 807 776 745 714 683 652 621 590 559 528 497 466 435 404 373 342 311 280 249 218 ...
output:
31 31 31 62 93 124 155 186 217 248 279 310 341 372 403 434 465 496 527 558 589 620 651 682 713 744 7...
result:
ok ok
Test #33:
score: 0
Accepted
time: 27ms
memory: 95056kb
input:
1000 996 995 999 998 997 994 993 992 991 988 985 1000 990 981 980 971 970 978 975 974 966 962 989 96...
output:
208 3 993 994 999 983 985 998 980 984 992 975 976 990 972 973 989 964 965 982 958 959 971 956...
result:
ok ok
Test #34:
score: 0
Accepted
time: 11ms
memory: 95052kb
input:
1000 994 991 990 989 998 997 1000 999 996 995 988 987 982 993 992 981 980 975 969 967 986 985 984 98...
output:
165 3 998 999 1000 989 991 993 975 977 979 970 976 978 965 973 974 964 967 971 947 948 951 94...
result:
ok ok
Test #35:
score: 0
Accepted
time: 19ms
memory: 95056kb
input:
1000 996 994 989 998 997 984 1000 999 995 979 992 978 972 993 983 991 990 968 988 987 986 985 967 97...
output:
187 3 991 993 995 984 986 988 981 982 985 975 978 979 964 966 970 957 962 965 954 961 963 951...
result:
ok ok
Test #36:
score: 0
Accepted
time: 15ms
memory: 95048kb
input:
1000 974 971 989 990 987 962 984 981 957 969 991 956 992 958 954 943 994 993 935 955 945 980 978 997...
output:
1 10 2 3 4 11 13 18 24 25 28 34
result:
ok ok
Test #37:
score: 0
Accepted
time: 11ms
memory: 95044kb
input:
1000 972 974 954 986 989 990 992 960 996 995 980 991 985 983 988 987 984 978 982 973 951 977 968 998...
output:
1 10 1 2 4 5 6 7 10 24 36 41
result:
ok ok
Test #38:
score: 0
Accepted
time: 12ms
memory: 95044kb
input:
1000 984 987 990 988 992 985 981 944 972 971 994 969 979 961 952 956 965 962 946 978 976 959 947 945...
output:
4 10 693 695 706 714 727 755 762 768 771 778 638 650 682 684 692 717 718 720 722 724 8 19 23 25 29...
result:
ok ok
Test #39:
score: 0
Accepted
time: 11ms
memory: 95020kb
input:
7 3 1 5 7 2 6 4
output:
2 3 2 5 7 1 3 6
result:
ok ok
Test #40:
score: 0
Accepted
time: 23ms
memory: 95020kb
input:
14 9 12 8 3 5 4 13 1 14 10 6 2 11 7
output:
2 4 4 6 11 14 1 2 7 9
result:
ok ok
Test #41:
score: 0
Accepted
time: 20ms
memory: 95024kb
input:
7 4 2 6 1 3 7 5
output:
2 3 4 5 7 2 3 6
result:
ok ok
Test #42:
score: 0
Accepted
time: 20ms
memory: 95024kb
input:
14 8 4 13 9 5 1 14 2 11 10 12 7 3 6
output:
2 4 6 8 13 14 2 5 10 11
result:
ok ok
Test #43:
score: 0
Accepted
time: 20ms
memory: 95008kb
input:
1 1
output:
1 1 1
result:
ok ok
Test #44:
score: 0
Accepted
time: 16ms
memory: 95020kb
input:
2 1 2
output:
1 2 1 2
result:
ok ok
Test #45:
score: 0
Accepted
time: 20ms
memory: 95020kb
input:
2 2 1
output:
2 1 2 1
result:
ok ok
Test #46:
score: 0
Accepted
time: 25ms
memory: 95020kb
input:
3 2 1 3
output:
1 2 2 3
result:
ok ok
Subtask #3:
score: 50
Accepted
Test #47:
score: 50
Accepted
time: 71ms
memory: 105776kb
input:
417116 94616 96638 262272 409338 282183 315333 301088 252968 337253 36291 294342 158636 175191 25272...
output:
1 1274 172 211 263 1176 1340 1963 2801 3097 3276 3395 3456 3780 4184 4270 5719 5933 5938 6234 6342 6...
result:
ok ok
Test #48:
score: 0
Accepted
time: 98ms
memory: 106160kb
input:
436094 152528 224667 145443 345955 141507 384489 106568 260071 419494 177352 312258 364875 318572 30...
output:
1 1307 1947 2367 3347 4600 4611 6692 6871 8129 8470 8689 10049 10269 10468 10753 11090 11993 12557 1...
result:
ok ok
Test #49:
score: 0
Accepted
time: 115ms
memory: 110540kb
input:
550922 27548 231241 71938 191182 201024 214286 405915 91068 418714 467023 186079 36613 320293 450206...
output:
1 1475 472 983 1105 1349 1648 2039 2337 2466 2556 2764 3554 3847 4174 4197 4437 4442 4937 4983 5388 ...
result:
ok ok
Test #50:
score: 0
Accepted
time: 227ms
memory: 121540kb
input:
967248 797949 282921 915223 615402 457485 321705 414144 86620 388934 606953 440839 448169 99139 4949...
output:
1 1958 1386 1507 1724 2235 2849 2992 3113 4918 5442 6535 6784 7402 8095 8352 8695 9159 9187 9437 101...
result:
ok ok
Test #51:
score: 0
Accepted
time: 51ms
memory: 101232kb
input:
222044 196297 148643 164889 27644 201810 183943 60092 219457 200511 36248 140579 124885 95788 81342 ...
output:
1 926 423 460 1124 1421 1841 2204 2304 2797 2900 3416 3621 3838 3894 3908 4269 4597 4650 4704 4714 4...
result:
ok ok
Test #52:
score: 0
Accepted
time: 247ms
memory: 227940kb
input:
1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34...
output:
1 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ...
result:
ok ok
Test #53:
score: 0
Accepted
time: 236ms
memory: 149636kb
input:
1000000 1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 ...
output:
1000000 1 1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 9...
result:
ok ok
Test #54:
score: 0
Accepted
time: 237ms
memory: 126760kb
input:
1000000 999001 999002 999003 999004 999005 999006 999007 999008 999009 999010 999011 999012 999013 9...
output:
1000 1000 999001 999002 999003 999004 999005 999006 999007 999008 999009 999010 999011 999012 999013...
result:
ok ok
Test #55:
score: 0
Accepted
time: 258ms
memory: 126740kb
input:
1000000 999001 998001 997001 996001 995001 994001 993001 992001 991001 990001 989001 988001 987001 9...
output:
1000 1000 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 11000 12000 13000 14000 15000 16000 170...
result:
ok ok
Test #56:
score: 0
Accepted
time: 13ms
memory: 95332kb
input:
10377 1195 3781 5570 1534 1258 6644 5042 1221 1102 8705 8701 8 6352 722 8142 7810 3101 3489 8482 223...
output:
1 194 12 121 132 263 281 298 307 610 795 817 830 881 905 1075 1133 1218 1271 1279 1307 1340 1413 146...
result:
ok ok
Test #57:
score: 0
Accepted
time: 175ms
memory: 116740kb
input:
771495 666031 737561 586493 693249 397715 36030 404452 757440 328128 261314 188611 105617 374102 865...
output:
1 1737 725 1264 3105 3477 3581 3677 4931 5209 5539 5740 5923 6241 6387 6543 6922 6961 7199 7370 7551...
result:
ok ok
Test #58:
score: 0
Accepted
time: 52ms
memory: 99968kb
input:
180311 130695 152662 23320 51572 160895 27572 33746 153157 132384 153929 134167 160043 28266 63840 1...
output:
1 846 241 353 732 838 1017 1039 1095 1169 1251 1494 1765 1963 2154 2780 3091 3593 3656 3806 4338 466...
result:
ok ok
Test #59:
score: 0
Accepted
time: 43ms
memory: 99380kb
input:
154198 70112 90787 79050 102012 125369 52775 62828 35601 95806 14594 11852 8595 136965 114839 121111...
output:
1 766 25 68 374 435 475 594 603 710 837 948 1351 1604 1724 1908 2069 2129 2203 2391 2679 3267 3322 3...
result:
ok ok
Test #60:
score: 0
Accepted
time: 203ms
memory: 116952kb
input:
777878 308299 298854 667082 524719 171593 173522 283850 209179 380713 519992 527145 356747 9865 5190...
output:
1 1761 2316 2939 2952 3450 4185 4591 6568 6899 7393 7455 7770 8374 8594 10608 11268 11488 11573 1210...
result:
ok ok
Test #61:
score: 0
Accepted
time: 134ms
memory: 109244kb
input:
514060 99093 335032 114719 133499 451143 353908 346149 264099 108696 405930 385203 448136 224024 164...
output:
1 1404 2907 3163 3205 3619 3808 6534 6741 6952 7047 7439 7625 7880 8960 9895 10803 11150 11342 11583...
result:
ok ok
Test #62:
score: 0
Accepted
time: 15ms
memory: 95020kb
input:
7 3 1 5 7 2 6 4
output:
2 3 2 5 7 1 3 6
result:
ok ok
Test #63:
score: 0
Accepted
time: 19ms
memory: 95024kb
input:
14 9 12 8 3 5 4 13 1 14 10 6 2 11 7
output:
2 4 4 6 11 14 1 2 7 9
result:
ok ok
Test #64:
score: 0
Accepted
time: 22ms
memory: 95024kb
input:
7 4 2 6 1 3 7 5
output:
2 3 4 5 7 2 3 6
result:
ok ok
Test #65:
score: 0
Accepted
time: 16ms
memory: 95020kb
input:
14 8 4 13 9 5 1 14 2 11 10 12 7 3 6
output:
2 4 6 8 13 14 2 5 10 11
result:
ok ok
Test #66:
score: 0
Accepted
time: 8ms
memory: 95008kb
input:
1 1
output:
1 1 1
result:
ok ok
Test #67:
score: 0
Accepted
time: 12ms
memory: 95020kb
input:
2 1 2
output:
1 2 1 2
result:
ok ok
Test #68:
score: 0
Accepted
time: 21ms
memory: 95020kb
input:
2 2 1
output:
2 1 2 1
result:
ok ok
Test #69:
score: 0
Accepted
time: 16ms
memory: 95020kb
input:
3 2 1 3
output:
1 2 2 3
result:
ok ok
Extra Test:
score: 0
Extra Test Passed