QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#382265 | #5352. 吉夫特 | bachbeo2007 | 100 ✓ | 42ms | 5456kb | C++23 | 788b | 2024-04-08 10:00:44 | 2024-04-08 10:00:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int maxn=220005;
int n,a[maxn],ans,sum[(1<<18)+5];
int query(int x){
int d=(x>>9),r=x&((1<<9)-1),res=0;
for(int i=d;;i=(i-1)&d){
res=(res+sum[i<<9|r])%mod;
if(i==0) break;
}
return res;
}
void update(int x,int val){
int d=x>>9,r=x&((1<<9)-1),nr=r^((1<<9)-1);
for(int i=nr;;i=(i-1)&nr){
sum[d<<9|r|i]=(sum[d<<9|r|i]+val)%mod;
if(i==0) break;
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
cin >> n;
for(int i=1;i<=n;i++) cin >> a[i];
for(int i=n;i>=1;i--){
int dp=query(a[i]);
update(a[i],dp+1);
ans=(ans+dp)%mod;
}
cout << ans << '\n';
}
詳細信息
Test #1:
score: 5
Accepted
time: 0ms
memory: 3628kb
input:
9 10 12 2 4 5 6 3 1 7
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 5
Accepted
time: 0ms
memory: 3712kb
input:
9 11 7 2 12 6 10 1 8 9
output:
11
result:
ok 1 number(s): "11"
Test #3:
score: 5
Accepted
time: 0ms
memory: 3560kb
input:
17 13 4 5 17 8 6 10 11 19 1 16 15 20 18 7 3 9
output:
21
result:
ok 1 number(s): "21"
Test #4:
score: 5
Accepted
time: 0ms
memory: 3648kb
input:
17 5 9 3 12 17 14 2 13 20 15 8 1 19 18 7 10 4
output:
25
result:
ok 1 number(s): "25"
Test #5:
score: 5
Accepted
time: 1ms
memory: 3736kb
input:
1911 3082 2173 2002 948 31 3132 394 1319 2245 3638 2283 3575 2105 673 3879 2094 487 547 3136 2010 726 1881 2219 1405 2216 2485 909 138 2788 3839 379 2888 2422 3861 1548 2765 2286 2031 762 3405 3363 3834 2552 2255 2158 3005 2597 3567 2964 1945 832 2732 2867 1729 3888 3471 1 1334 568 1341 2828 3223 24...
output:
704770
result:
ok 1 number(s): "704770"
Test #6:
score: 5
Accepted
time: 0ms
memory: 3660kb
input:
1911 3580 2819 2213 1742 2397 2088 1950 1777 2296 56 1606 2987 3012 712 474 188 894 1439 3642 3896 3953 1158 272 2523 1379 3408 984 3517 3317 985 2697 2192 79 2378 1235 3275 2837 249 3611 1548 1818 3433 1436 2571 385 361 1888 2172 1866 2542 2861 327 3393 2510 669 1088 2823 843 576 3352 3303 2 2943 1...
output:
557002
result:
ok 1 number(s): "557002"
Test #7:
score: 5
Accepted
time: 1ms
memory: 3580kb
input:
1911 577 3076 1041 3574 1307 3239 3235 1174 1581 3012 2911 910 2242 590 2383 123 1997 3980 2871 1049 1127 1569 3375 1193 2799 1113 2710 657 1414 2763 2764 1358 1340 58 302 2335 3015 772 3713 1808 3732 3531 1405 2467 3255 640 19 1138 2949 2372 3797 3548 2198 3603 3510 1507 1701 1537 2145 2953 71 425 ...
output:
740269
result:
ok 1 number(s): "740269"
Test #8:
score: 5
Accepted
time: 1ms
memory: 3608kb
input:
1911 2425 3616 2500 2743 364 1444 1988 3972 2418 166 2590 2382 1916 2817 1580 3634 2281 3259 1465 1720 3499 661 1799 466 1359 2984 926 3661 1214 3671 1543 3369 2570 3482 1394 1957 452 2451 3969 69 1639 2008 3138 1039 1454 2100 2413 3157 348 1263 242 3083 2694 3907 2079 3622 3797 1497 3031 2518 93 65...
output:
432697
result:
ok 1 number(s): "432697"
Test #9:
score: 5
Accepted
time: 1ms
memory: 4544kb
input:
2017 218488 42146 96090 102449 15778 35101 229920 73206 112761 175413 231110 89889 227034 226135 69566 153940 218457 49578 25977 90447 177174 65832 223330 154455 180921 201160 8206 41483 209863 137022 147690 59067 53067 21207 114952 15017 72124 61154 196588 8669 66411 146274 199945 7208 11073 172639...
output:
13485
result:
ok 1 number(s): "13485"
Test #10:
score: 5
Accepted
time: 1ms
memory: 4556kb
input:
2017 58546 180201 33517 180306 41829 69393 210231 101666 83924 107960 136142 98214 4082 111929 210895 207073 178036 77822 32162 38249 178215 114967 220451 60485 53001 199469 209842 38166 39473 155065 13334 127632 232783 196767 149134 134986 159119 55559 70565 26664 2486 162103 33658 76508 33460 2003...
output:
14904
result:
ok 1 number(s): "14904"
Test #11:
score: 5
Accepted
time: 1ms
memory: 4544kb
input:
2017 134932 111024 158301 75899 138543 199027 225859 166431 52154 17759 65165 153873 10946 6522 131520 19880 166779 146246 89021 29060 137393 220146 16277 23931 139244 224049 133320 217458 82823 2817 58721 25540 121394 55304 191991 127668 44301 69687 120542 37875 140002 45120 1809 224985 206618 1227...
output:
17461
result:
ok 1 number(s): "17461"
Test #12:
score: 5
Accepted
time: 1ms
memory: 4476kb
input:
2017 4701 39411 149987 70796 209030 179630 42614 173569 37981 99957 31464 21714 7280 224136 72756 84994 133276 181984 225241 164622 220405 16597 225326 136841 178121 26357 61695 213541 99711 217489 41531 21745 49009 189279 45861 134952 109193 229171 222541 52575 24760 95790 148605 36095 66769 116137...
output:
20791
result:
ok 1 number(s): "20791"
Test #13:
score: 5
Accepted
time: 0ms
memory: 4488kb
input:
2017 151295 185649 33154 61834 40666 81266 162689 11623 158620 133790 177744 1157 80979 86094 70584 186428 88732 108761 1500 104902 82475 138087 200586 62572 111550 168497 63324 73505 129108 56603 169535 144304 190548 138531 152071 168001 34716 188228 789 66086 49592 47818 205093 184168 139610 95124...
output:
13689
result:
ok 1 number(s): "13689"
Test #14:
score: 5
Accepted
time: 0ms
memory: 4576kb
input:
2017 15171 129020 170855 112061 206378 38173 182241 44732 112693 167407 14635 106857 182529 231249 207147 53300 66170 95076 158721 110249 54178 57249 185184 76284 206490 10836 130281 174822 12189 54741 24931 154640 36156 38813 125811 86557 217820 110909 26703 223518 94039 168755 66544 171619 99162 5...
output:
11323
result:
ok 1 number(s): "11323"
Test #15:
score: 5
Accepted
time: 23ms
memory: 4868kb
input:
100084 96775 146227 118981 114973 155636 61361 52797 135727 100014 79458 156871 103337 29900 199714 230568 94576 75542 212817 209761 88670 231950 29049 39739 116643 64652 38747 205150 88562 100854 98968 44756 203240 48724 54787 21632 84323 144483 62709 28086 22188 188048 71555 12543 23317 28827 1391...
output:
803835892
result:
ok 1 number(s): "803835892"
Test #16:
score: 5
Accepted
time: 18ms
memory: 4992kb
input:
100084 139251 60142 212660 92363 158267 160993 152491 56810 53129 130925 57394 6149 6890 24040 75331 215334 156913 183486 154254 122230 218647 30542 3586 171680 123474 79254 226166 67001 107547 213092 162489 148459 194026 123261 47316 169632 7591 218956 106070 22672 131513 35898 140366 148068 177953...
output:
721038477
result:
ok 1 number(s): "721038477"
Test #17:
score: 5
Accepted
time: 22ms
memory: 4856kb
input:
100084 22285 149931 11500 153224 30178 163119 143862 150352 124529 621 133063 200406 16669 192435 80930 2140 227212 195940 160396 80486 173240 98023 201478 168471 151466 37413 39155 139906 23157 86686 25929 193301 171733 149512 70575 419 66441 151079 38113 20795 17866 137677 59472 191738 185583 1129...
output:
644845043
result:
ok 1 number(s): "644845043"
Test #18:
score: 5
Accepted
time: 42ms
memory: 5456kb
input:
211985 56745 85888 203224 149508 196917 19806 94439 168072 115773 192410 186668 14937 30665 203706 92787 9902 225180 34799 226899 194570 113245 39343 109015 20416 27096 194910 33879 30845 28540 188961 77789 55655 201080 75103 13926 184282 13956 140977 77233 41733 68819 185566 123481 224338 222106 52...
output:
355662008
result:
ok 1 number(s): "355662008"
Test #19:
score: 5
Accepted
time: 42ms
memory: 5376kb
input:
211985 17372 3705 120938 11738 191475 149356 210407 31291 23060 212571 125053 3610 134473 109284 183750 37338 161312 233161 8010 126517 123679 203406 145432 19862 37462 88050 107637 228310 15475 143790 163127 204766 198240 108908 150992 67252 194118 85988 219394 69937 214818 174585 97056 198060 2878...
output:
435408882
result:
ok 1 number(s): "435408882"
Test #20:
score: 5
Accepted
time: 41ms
memory: 5384kb
input:
211985 50512 91546 110194 112869 158611 177161 168794 27149 91398 174332 95167 14897 230526 196900 118434 103876 171304 145254 217175 120599 121396 128677 99045 185219 43268 1193 51909 111058 152412 194840 72974 86279 147516 186841 17162 39745 20603 117064 179455 146597 21013 152014 204298 223045 18...
output:
474235485
result:
ok 1 number(s): "474235485"
Extra Test:
score: 0
Extra Test Passed