QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#100842#1805. Bunch of Paperckiseki#AC ✓1146ms20884kbC++201.5kb2023-04-28 12:40:462023-04-28 12:40:48

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-28 12:40:48]
  • 评测
  • 测评结果:AC
  • 用时:1146ms
  • 内存:20884kb
  • [2023-04-28 12:40:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int mod = 1000000007;
const int maxn = 1000025;

int madd(int a, int b) {
    return a + b >= mod ? a + b - mod : a + b;
}

struct BI {
    vector<int> evt;
    int b[maxn];
    void revert() {
        for (int p: evt)
            for (++p; p < maxn; p += p & -p)
                b[p] = 0;
    }
    void add(int p, int v) {
        evt.emplace_back(p);
        for (++p; p < maxn; p += p & -p)
            b[p] = madd(b[p], v);
    }
    int query(int p) {
        int r = 0;
        for (++p; p > 0; p -= p & -p)
            r = madd(r, b[p]);
        return r;
    }
} BIT;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    vector<int> u;
    vector<vector<int>> v(n, vector<int>(k));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            cin >> v[i][j];
            u.push_back(v[i][j]);
        }
    }

    sort(u.begin(), u.end());
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            v[i][j] = lower_bound(u.begin(), u.end(), v[i][j])
                - u.begin();
        }
    }
    BIT.add(0, 1);

    vector<int> dp(k);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            dp[j] = BIT.query(v[i][j]);
        }
        BIT.revert();
        for (int j = 0; j < k; j++) {
            BIT.add(v[i][j], dp[j]);
        }
    }

    int z = 0;
    for (int j = 0; j < k; j++)
        z = madd(z, dp[j]);
    cout << z << '\n';
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3420kb

input:

2 2
2 4
1 5

output:

2

result:

ok answer is '2'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3400kb

input:

2 3
4 5 6
1 2 3

output:

0

result:

ok answer is '0'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3364kb

input:

20 20
2 8 12 17 19 29 41 53 57 62 63 65 67 70 71 74 76 77 96 100
2 3 9 13 15 16 20 26 28 33 38 39 46 51 58 59 74 92 93 99
2 5 6 9 19 20 22 24 26 35 41 45 56 60 62 74 76 81 83 96
3 7 10 11 13 15 17 20 22 26 34 35 43 59 68 78 82 83 85 93
1 7 11 14 17 26 37 41 45 49 62 63 64 67 71 74 88 89 91 94
12 15 ...

output:

188926982

result:

ok answer is '188926982'

Test #4:

score: 0
Accepted
time: 48ms
memory: 5000kb

input:

22 4575
357111 512738 907585 992747 1020767 1475752 1511599 1845743 2038200 2136464 2259444 2319582 2379052 2552146 2618540 2671770 2861814 3011069 3078663 3235215 3434184 3659712 3669949 4139002 4157133 4394350 4533047 4675889 5404911 5473089 5527137 5715859 5864425 5953471 6099738 6307489 6342541 ...

output:

546103424

result:

ok answer is '546103424'

Test #5:

score: 0
Accepted
time: 27ms
memory: 5060kb

input:

14 7143
248843 336893 841913 1452478 1494993 1546499 1627788 1824585 1908773 1917041 1985353 2044000 2192203 2227944 2304039 2361746 2555661 2659933 2808951 3109865 3164698 3246846 3256690 3306842 3389770 3498125 3694733 3838700 3869704 4087021 4142006 4193223 4293018 4307506 4420134 4650545 4651347...

output:

325808936

result:

ok answer is '325808936'

Test #6:

score: 0
Accepted
time: 1034ms
memory: 19592kb

input:

95 9455
204707 463983 617350 782176 1326350 1533528 2071942 2138765 2215057 2318542 2370364 2524512 2825377 2901752 2956091 3017182 3423140 3551501 3565993 3612389 3732101 3940984 4159249 4170251 4217234 4280486 4307214 4385048 4422955 4476365 4492803 4578088 4654133 4661368 4697563 5028192 5482587 ...

output:

853465322

result:

ok answer is '853465322'

Test #7:

score: 0
Accepted
time: 109ms
memory: 5416kb

input:

68 1847
1870124 2313651 2663134 2731197 3126592 3127301 3162667 4291237 4718181 4797148 5304125 5457518 5472741 6130320 6188845 6269442 6604462 6619391 6963292 7560315 7787773 8263138 8958398 8958551 9418526 9714980 9791474 10816299 10971107 11752791 12202747 12403771 12436436 13402565 13588388 1499...

output:

759542169

result:

ok answer is '759542169'

Test #8:

score: 0
Accepted
time: 150ms
memory: 6448kb

input:

72 2282
335952 819888 948767 1235870 1342966 2398420 2696514 2929412 2991322 3068341 4100241 5059169 6160967 7217712 7361367 8273082 9148985 9182844 9359426 10819092 10846150 10891596 10947810 11220225 11493540 11625715 12132529 12248021 12276013 12453439 12781874 12844580 13137663 13562771 13853444...

output:

76643643

result:

ok answer is '76643643'

Test #9:

score: 0
Accepted
time: 33ms
memory: 4740kb

input:

14 5711
207344 215943 481072 553769 919358 1038543 1254781 1465635 1743631 1839856 1877189 1919362 2049312 2320675 2343994 2637913 2844478 3078477 3079646 3359105 3420973 3424749 3609173 3743287 3859829 3944486 4634000 4718282 4817628 4850950 5003742 5191679 5195305 5313489 5416786 5484278 5583367 5...

output:

133480544

result:

ok answer is '133480544'

Test #10:

score: 0
Accepted
time: 4ms
memory: 3616kb

input:

2 5018
174510 349651 600116 990924 1096753 1250152 1503986 2547032 2844790 3097896 3427622 3531061 3690115 4443974 4468973 4704907 4740215 4749240 4885392 4904065 5082413 5258140 5282890 5307390 5331354 5493043 5535959 5662165 5718263 5734507 5742153 5766867 5815853 6066797 6884956 7155146 7354661 7...

output:

12683607

result:

ok answer is '12683607'

Test #11:

score: 0
Accepted
time: 277ms
memory: 7140kb

input:

99 2269
896824 1290940 2894715 3300947 3936704 4029376 4224433 4252677 4552642 4624403 5371063 5469706 5888584 6457456 6859763 7150060 7286901 7838280 7911341 8039855 8286414 9688330 10324775 10923635 11081783 11085888 11348034 12043136 13261348 13749526 13794375 14060156 14244872 15358351 15497026 ...

output:

847922013

result:

ok answer is '847922013'

Test #12:

score: 0
Accepted
time: 45ms
memory: 4072kb

input:

52 1009
445669 1086899 2645353 4525370 4754027 4948451 5130300 5722294 5804384 5954877 6359930 7476660 7602058 7993779 8249412 10160785 10211058 10372405 12478893 12999783 13078296 13954913 15540943 16062832 16337605 20455737 20592258 20653843 20892602 22735054 22748421 23633309 24567607 24987030 25...

output:

262035125

result:

ok answer is '262035125'

Test #13:

score: 0
Accepted
time: 228ms
memory: 7380kb

input:

80 2977
490526 1198100 1276006 1465634 1546670 2713842 2829859 3174283 3175938 3695032 4075316 4424208 4733906 4742512 4858737 5261247 5430352 5928945 6150413 6795575 7225447 7252139 7885501 8615883 8739698 9363396 9504644 9733014 10066602 10158089 10323187 11093068 11918825 12051504 12556432 126432...

output:

863472797

result:

ok answer is '863472797'

Test #14:

score: 0
Accepted
time: 3ms
memory: 3548kb

input:

6 2482
470655 1811724 2398225 3148659 3254356 4461354 5727739 5729536 5847086 5902012 5936255 6408061 6663155 6768451 6791854 7918733 9027015 9431554 10158614 10635004 11022624 11218249 11340437 11444499 11612328 11756420 11962461 12240668 13093319 13237710 14057505 14817947 14856799 16131337 162277...

output:

237627015

result:

ok answer is '237627015'

Test #15:

score: 0
Accepted
time: 814ms
memory: 18828kb

input:

91 8188
14643 287780 453834 629966 681255 834381 846062 1027326 1115955 1223618 1323306 1378498 1551799 1659463 2026460 2257967 2264519 2368566 2545366 2691376 2762747 3000250 3071134 3138557 3394037 3420828 3491513 3598804 3893428 3937183 3950361 3967329 4005097 4125466 4165297 4310980 4310987 4482...

output:

148105081

result:

ok answer is '148105081'

Test #16:

score: 0
Accepted
time: 998ms
memory: 19888kb

input:

97 9430
224097 460358 644960 845008 959292 1019155 1026945 1097168 1139080 1188654 1190595 1272751 1423020 1451470 1459289 1681905 1686094 1762239 2083365 2365570 2428794 2466337 2758281 2767464 2830269 2962160 2989325 3099578 3517494 3531759 3553656 3751432 3791113 4007280 4132213 4202496 4203026 4...

output:

728999448

result:

ok answer is '728999448'

Test #17:

score: 0
Accepted
time: 565ms
memory: 16912kb

input:

72 8862
15424 320218 466562 668915 963907 1134408 1150808 1238372 1341998 1531159 1555658 1645930 1677261 1758344 2076578 2245122 2256499 2277915 2311273 2340161 2375657 2458221 2519390 2526383 2670684 2690318 2882012 2951129 3182021 3292254 3490146 3505521 3871951 3924442 3942111 3999761 4116019 41...

output:

237354419

result:

ok answer is '237354419'

Test #18:

score: 0
Accepted
time: 328ms
memory: 9828kb

input:

81 3941
120666 425027 463709 827174 1007375 1082362 1442986 1715362 1844752 1859746 2280726 3008775 3126939 3168820 3382823 3450036 3930540 4150024 4257251 4261125 4333549 5082424 5815757 6600974 7267882 7564575 7919626 7930344 8019668 8066678 8340666 8432673 8651555 9559242 9965371 9990466 10031833...

output:

233113713

result:

ok answer is '233113713'

Test #19:

score: 0
Accepted
time: 295ms
memory: 7560kb

input:

99 2629
273247 591944 827596 1465996 1859497 2789434 2937085 3514254 3708072 4486454 4771554 5170738 5308656 5380857 6591774 7330873 7799846 7804239 8231240 8263467 8295323 8714975 8862295 9713850 9783832 10510114 10616419 11178822 11727657 12231741 12587326 12771398 13961753 14153534 14217691 14590...

output:

578290030

result:

ok answer is '578290030'

Test #20:

score: 0
Accepted
time: 333ms
memory: 11608kb

input:

55 8471
45602 211898 434262 465572 542682 706452 747757 1134622 1175854 1309464 1375681 1522552 1736349 1837905 1941866 2062669 2064677 2098644 2341361 2420497 2859903 3039308 3098916 3356887 3360352 3414518 3710760 4172205 4217294 4427393 4586664 4644534 4863903 5138949 5202744 5555634 5597077 5598...

output:

791155375

result:

ok answer is '791155375'

Test #21:

score: 0
Accepted
time: 399ms
memory: 11704kb

input:

67 7160
151682 164439 252086 252292 400530 530088 533229 682193 693459 698960 730411 1123592 1205615 1335086 1504628 1549174 1808397 2015171 2128505 2297490 2705306 2728784 3477748 3532843 3759603 3891544 4136002 5104132 5226264 5759002 6013371 6060901 6128718 6619802 6777939 7055193 7380039 7607119...

output:

832229533

result:

ok answer is '832229533'

Test #22:

score: 0
Accepted
time: 189ms
memory: 9396kb

input:

46 6101
339428 363831 1017020 1117706 1219403 1392026 1840231 1901161 2017109 2047635 2151088 2341425 2656263 2682378 3132020 3170769 3175368 3329848 3368756 3487233 3610829 3678045 3961341 4031681 4081927 4429243 4517638 4527731 4608073 4800080 4865967 5191699 5224446 5635143 5688903 5834155 592154...

output:

792228433

result:

ok answer is '792228433'

Test #23:

score: 0
Accepted
time: 101ms
memory: 6424kb

input:

38 4396
148773 237665 401692 420883 422399 626720 792010 915254 1608188 1651689 2291807 2894793 3082638 3257472 3276613 3542016 3773369 3988741 4122661 4422801 4629128 4779638 4829545 5070406 5170716 5598311 5695201 5738116 5889556 5925291 6126022 6884744 6914310 6994620 7018091 7660902 7782276 8617...

output:

192173734

result:

ok answer is '192173734'

Test #24:

score: 0
Accepted
time: 1146ms
memory: 20824kb

input:

100 10000
157609 274544 366050 922635 930207 1056538 1163621 1189172 1299362 1381561 1481082 1607775 2028837 2242683 2585767 3116549 3175796 3207254 3313071 3838938 3900446 4000630 4095068 4251076 4259347 4337917 4363691 4406635 4563022 4631644 4880312 4972984 5066811 5230966 5357548 5365694 5517202...

output:

138561463

result:

ok answer is '138561463'

Test #25:

score: 0
Accepted
time: 1124ms
memory: 20884kb

input:

100 10000
39688 390645 708366 725989 827327 911053 1457124 1623251 1864369 1967475 1981499 2015948 2020726 2360413 2452426 2474950 2761315 2828874 2899221 2955730 3164132 3210836 3227014 3396684 3559504 3702170 3756516 3761817 3980667 4018483 4047710 4356806 4400591 4401323 4408488 4440121 4479099 4...

output:

797058557

result:

ok answer is '797058557'

Test #26:

score: 0
Accepted
time: 3ms
memory: 3448kb

input:

83 12
11750763 41152096 135603631 177010583 198443227 208099265 299899874 391862575 409273868 534010063 853560926 971359874
52176953 150308026 276730080 296403699 321552986 336317813 419885825 729000723 881956287 904286539 904361151 906357475
40206580 76108868 157382491 159884223 168084009 215930125...

output:

0

result:

ok answer is '0'

Test #27:

score: 0
Accepted
time: 53ms
memory: 6348kb

input:

16 9801
4965 15609 202122 312097 342440 430259 435272 502426 906510 925073 931341 1113633 1143557 1160889 1201468 1252979 1276928 1335507 1351810 1368230 1440392 1479444 1602994 1788351 1810234 1888808 1899601 2035317 2076685 2139933 2200201 2292556 2401787 2642505 2709232 2795066 2829968 2878411 28...

output:

369473301

result:

ok answer is '369473301'

Test #28:

score: 0
Accepted
time: 71ms
memory: 6064kb

input:

30 4539
11851 89626 184084 248265 264185 423068 447729 668303 1239370 1276073 1486034 1713868 1719778 2105771 2284449 3056072 3316219 3837377 3872847 4635457 5270701 6446100 6728962 6743586 6815484 7311185 7364701 7402425 7496259 7941479 8438169 8809356 9087556 9271680 9836126 10035968 10477121 1062...

output:

874778706

result:

ok answer is '874778706'