QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#704857#5535. PopealaTheZone100 ✓236ms23316kbC++112.6kb2024-11-02 21:18:102024-11-02 21:18:12

Judging History

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

  • [2024-11-02 21:18:12]
  • 评测
  • 测评结果:100
  • 用时:236ms
  • 内存:23316kb
  • [2024-11-02 21:18:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL inf=0x3f3f3f3f3f3f3f3f;
const int N=2e4+4,M=52;
int n,m,S;
LL f[M][N],s[N],c[M],p[N][M];
char ch[M][N];
LL st[M][N][15],lg[N];
void init(int x)
{
    lg[1]=0;
    for(int i=2;i<=m+1;i++)
    {
        lg[i]=lg[i/2]+1;
    }
    for(int j=0;j<=n;j++)
    {
        for(int i=0;i<=m;i++)
        {
            st[j][i][0]=f[x][i]-s[i]*j;
        }
        for(int k=1;k<=14;k++)
        {
            for(int i=0;i<=m;i++)
            {
                st[j][i][k]=min(st[j][i][k-1],st[j][i+(1<<(k-1))][k-1]);
            }
        }
    }
}
LL query(int k,int j,int x,int y)
{
//    cout<<'*'<<j<<' '<<x<<' '<<y<<'*';
/*    LL ret=inf;
    for(int i=x;i<=y;i++)
    {
        ret=min(ret,f[k][i]-j*s[i]);
    }
    return ret;*/
    return min(st[j][x][lg[y-x+1]],st[j][y-(1<<lg[y-x+1])+1][lg[y-x+1]]);
}
LL l[N],r[N],v[N];
int main()
{
    scanf("%d%d%d",&n,&m,&S);
    for(int i=1;i<=m;i++)
    {
        scanf("%lld",&s[i]);
        s[i]+=s[i-1];
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%s",ch[i]+1);
    }
    f[0][0]=0;
    for(int t=1;t<=n;t++)
    {
        c[t]=0;
    }
    for(int j=1;j<=m;j++)
    {
    for(int t=1;t<=n;t++)
    {
        if(ch[t][j]=='0')
        {
            c[t]=j;
        }
        p[j][t]=c[t];
    }
    sort(p[j]+1,p[j]+n+1);
    p[j][n+1]=j;
    }
    memset(f,0x3f,sizeof(f));
    f[0][0]=0;
    for(int i=1;i<=S;i++)
    {
    //    cout<<i<<endl;
        for(int k=0;k<=n;k++)
        {
            l[k]=0,r[k]=-1,v[k]=inf;
        }
        for(int j=1;j<=m;j++)
        {
            f[i][j]=inf;
            int pre=0;
            for(int k=1;k<=n+1;k++)
            {
            //    cout<<p[j][k]<<' ';
                if(pre==p[j][k])
                {
                    continue;
                }
                while(pre==l[k-1]&&r[k-1]<p[j][k]-1)
                {
                    r[k-1]++;
                    v[k-1]=min(v[k-1],f[i-1][r[k-1]]-(k-1)*s[r[k-1]]);
                }
                if(pre>r[k-1])
                {
                    v[k-1]=inf;
                    l[k-1]=pre;r[k-1]=pre-1;
                    while(r[k-1]<p[j][k]-1)
                    {
                    r[k-1]++;
                    v[k-1]=min(v[k-1],f[i-1][r[k-1]]-(k-1)*s[r[k-1]]);
                    }
                }
                f[i][j]=min(f[i][j],s[j]*(k-1)+v[k-1]);
                pre=p[j][k];
            }
        }
        printf("%lld\n",f[i][m]);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 8
Accepted

Test #1:

score: 8
Accepted
time: 0ms
memory: 17196kb

input:

2 3 3
4 3 5
101
110

output:

0
8
16

result:

ok 3 lines

Test #2:

score: 8
Accepted
time: 0ms
memory: 16968kb

input:

35 40 15
3657 2870 9633 4742 6403 1197 1327 9983 5095 1033 2356 2681 9948 6851 6494 1965 6698 5860 8718 3453 9739 5794 7452 9556 5798 5141 4009 1869 2474 6480 8270 6280 4446 8052 2155 3226 1667 843 2851 6305
1001111110101111111111111110111111111111
1111111111111111111111111111111111111111
1111111111...

output:

2237081
2324849
2390859
2474206
2512547
2586745
2634155
2721923
2787933
2965077
3067335
3199190
3273388
3320798
3497942

result:

ok 15 lines

Subtask #2:

score: 9
Accepted

Test #3:

score: 9
Accepted
time: 6ms
memory: 15708kb

input:

50 500 50
2038 388 7128 2805 5579 3731 7082 6271 5626 5928 8728 304 2767 8798 8311 8389 7924 1727 8612 7438 6588 7056 4588 3823 4615 4201 6337 370 1178 2694 7211 5841 6159 5419 7907 7080 1436 1867 4643 7361 1743 3185 9089 2317 593 9466 8700 9757 8776 8077 1274 1951 4362 1077 3344 2876 4067 1267 8350...

output:

0
95786
114798
244998
580014
717459
985251
1168070
1515088
1816096
2029416
2220312
2309682
2390264
2424480
2759496
2896941
3164733
3347552
3694570
3964964
4276878
4561422
4894290
5003990
5139573
5527629
5756985
5971037
6262492
6443498
6612787
6894109
7085248
7273926
7535859
7746387
8014179
8196998
8...

result:

ok 50 lines

Test #4:

score: 9
Accepted
time: 4ms
memory: 18700kb

input:

48 500 50
446 3830 1528 4330 8911 4558 846 2868 9188 1998 3322 1814 2987 5215 7205 9816 5235 4701 4702 6676 2319 1784 5640 9926 8364 4807 4576 1935 9599 4040 2345 1633 4142 6357 9262 9937 4120 3173 7766 9601 8936 3122 4307 4714 6174 6772 9560 3922 8704 5953 5511 2445 7737 4847 3210 886 6021 9644 803...

output:

0
21408
78954
207754
262858
446698
518514
726354
1052758
1260598
1379440
1514236
1803401
1987241
2059057
2266897
2437072
2676962
2919983
3054779
3409065
3587711
3747167
3834239
3977615
4217505
4548935
4878013
5209443
5467997
5688991
5975512
6111756
6195604
6455044
6809330
7115552
7538608
7744528
783...

result:

ok 50 lines

Test #5:

score: 9
Accepted
time: 4ms
memory: 15652kb

input:

50 500 50
6699 143 4520 2827 506 5190 6117 6490 2219 1723 8693 6430 268 7651 2239 5694 9812 7679 7286 919 6700 9632 2940 3900 9214 7738 3303 1608 8103 406 8651 1959 3280 9029 9278 8175 7398 1742 2818 5354 6941 7740 5687 2549 5345 2267 516 1112 3027 1353 238 8848 8516 1674 4127 8982 4214 1833 2398 94...

output:

0
75650
328273
403923
602803
686125
761775
1016085
1263535
1517845
1718599
1829161
2142083
2330921
2591745
2785985
3027953
3209469
3407613
3617926
3687751
3942061
4152895
4239093
4493403
4755137
4967314
5030524
5284834
5590684
5743514
5867414
6091442
6345752
6651602
6810900
6934800
7158828
7573484
7...

result:

ok 50 lines

Subtask #3:

score: 9
Accepted

Test #6:

score: 9
Accepted
time: 34ms
memory: 16992kb

input:

48 2200 50
337 3453 6137 1365 4085 2098 573 5755 4273 791 629 3815 1240 5977 8595 9987 9020 5999 9071 655 8343 4000 5410 3356 4673 7505 8440 259 5473 9902 7131 1896 8264 816 2911 1052 8757 5517 4111 9878 7684 3757 5880 6524 6338 7356 1354 3100 9447 8440 8994 4598 1942 7759 3915 3175 980 5528 3090 77...

output:

0
0
0
0
0
0
660
1718
3383
7088
12274
27776
53830
98036
155047
181101
309819
445072
559490
686254
836830
992254
1134321
1269574
1383992
1510756
1661332
1775704
1904422
2038217
2154093
2280857
2431433
2586857
2729260
2884684
3039287
3166051
3321475
3488325
3640414
3790990
3917932
4068508
4209483
43362...

result:

ok 50 lines

Test #7:

score: 9
Accepted
time: 43ms
memory: 18136kb

input:

50 3000 50
5950 9687 1494 6034 4761 8813 28 5374 6549 5784 7122 6628 7625 1592 8053 6314 9372 6900 648 6460 9268 1116 8934 4230 1174 7325 9231 2614 772 4884 4623 9657 1066 3497 7229 1688 8252 2304 5745 1326 9955 3210 8024 6132 3843 5064 2006 6419 71 2345 198 8006 1436 7082 1269 7055 9759 5497 6895 1...

output:

0
0
0
245
1568
12203
29667
79846
154150
252262
360356
458468
602146
700258
855538
993529
1104983
1252566
1350678
1505958
1643949
1764141
1943732
2063924
2253778
2462901
2583093
2772947
2989382
3146278
3362713
3520158
3736593
4006843
4193364
4383218
4628512
4756549
5002392
5130429
5400679
5674379
588...

result:

ok 50 lines

Test #8:

score: 9
Accepted
time: 45ms
memory: 18900kb

input:

50 4000 50
4834 5642 7536 3065 7147 350 2008 8039 3592 4684 3322 807 7023 2937 6910 1227 2027 164 2114 9086 8542 3383 552 4788 35 1988 3351 3344 1515 47 1778 5064 6486 3858 6470 8794 796 4418 93 8192 6908 6828 5856 8724 4727 5801 9128 149 9060 442 7609 4429 555 476 6766 8033 9525 7092 1087 9092 2261...

output:

0
0
960
3400
93350
160662
329266
374002
610868
736276
973142
1103078
1339944
1616402
1841701
1994630
2231496
2318246
2480630
2648601
2682901
2919767
3196225
3461989
3715674
3876356
3982056
4181769
4344330
4605432
4711132
5059032
5184080
5347130
5468027
5539945
5625289
5753285
5838629
6086765
6200903...

result:

ok 50 lines

Subtask #4:

score: 74
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #9:

score: 74
Accepted
time: 168ms
memory: 22164kb

input:

48 20000 50
1549 695 1682 1506 1690 1775 1618 1612 1266 143 616 1765 8 478 1380 917 565 377 1666 483 25 1352 1436 47 865 885 1243 1364 13 880 722 1434 1839 707 1504 1694 285 1764 147 53 1261 854 130 1779 1770 245 1328 717 865 1423 1256 1697 1335 1435 342 1119 797 1005 1042 249 1406 781 1593 1326 770...

output:

0
53808
90750
99342
173694
185622
259974
293334
307305
349887
399002
457599
506714
576107
582305
588441
651047
690607
718207
771103
784489
804649
879001
912361
991415
1063703
1142820
1147635
1153771
1228123
1261483
1340537
1412825
1444220
1467015
1508422
1574727
1616134
1639813
1705717
1747525
18085...

result:

ok 50 lines

Test #10:

score: 74
Accepted
time: 178ms
memory: 21344kb

input:

50 20000 50
2155 1356 2006 1754 166 1316 977 849 1655 313 1898 1196 1503 362 1396 1324 100 203 739 1092 1509 563 416 694 979 1799 129 1491 841 1738 1561 1048 2168 1805 997 1000 515 616 913 985 1955 2017 767 525 437 1362 924 1608 1532 373 1852 402 400 1125 998 1927 1270 1450 1531 4 1145 653 2150 2075...

output:

0
42150
129846
182146
225496
278996
299037
370941
448459
529603
599941
604603
687119
728975
820039
891943
917813
989717
1012924
1049874
1092024
1145532
1206982
1227366
1262066
1304216
1353166
1407416
1449566
1520843
1561103
1610053
1681957
1706453
1778357
1819880
1891784
1969302
2012019
2085078
2125...

result:

ok 50 lines

Test #11:

score: 74
Accepted
time: 236ms
memory: 23316kb

input:

50 20000 50
1320 724 990 1156 1889 1360 168 55 993 700 1041 1154 1913 1742 1088 2353 818 654 1234 1964 923 693 713 1013 859 327 1682 311 191 1788 567 2372 1413 1699 525 518 2049 2352 1516 239 555 1279 1850 1641 2036 369 2299 253 811 1693 112 50 850 407 435 1563 459 990 1234 1984 598 326 126 335 211 ...

output:

0
30527
95207
127787
176297
232941
321724
361104
368428
398955
447612
481212
532221
589921
679832
765190
816326
912566
968909
999436
1061136
1157372
1200753
1234710
1268221
1317858
1345118
1375645
1441093
1450643
1481170
1564250
1594777
1691017
1777416
1853641
1879541
1910068
2006308
2106709
2178833...

result:

ok 50 lines

Test #12:

score: 74
Accepted
time: 227ms
memory: 23124kb

input:

50 20000 50
2242 1784 993 1094 1614 2126 1367 1612 1650 1678 1118 1427 998 629 453 1147 1302 912 326 2032 1422 1367 1100 800 1423 87 1191 706 1180 1553 905 2129 1184 105 1632 1549 888 1426 1597 548 1844 1857 1904 1174 297 175 421 1397 1116 2228 1860 1777 854 351 832 1615 633 797 1088 878 1027 729 23...

output:

0
111279
201300
248964
303664
382750
484798
551781
591897
642089
646103
736677
836527
848727
945027
987843
1061734
1069722
1099672
1183122
1228386
1306265
1403336
1471757
1511757
1577701
1584411
1641579
1675467
1734467
1805905
1850250
1954571
2011127
2017837
2096173
2170525
2212261
2279283
2357536
2...

result:

ok 50 lines

Test #13:

score: 74
Accepted
time: 223ms
memory: 23220kb

input:

50 20000 50
1162 988 1623 113 2324 1779 448 1217 191 1734 582 1233 2051 540 2389 2155 237 2249 2107 1568 972 2301 1159 2072 396 1453 834 1081 2368 1034 1473 331 1916 1358 622 1614 84 34 1111 1113 1322 1043 561 1729 430 398 2258 1259 26 1875 785 946 1447 1362 1387 68 1089 1280 440 1903 1823 2212 872 ...

output:

0
54614
102038
181565
187102
298654
385825
407329
466962
476321
561287
589223
650873
753423
780423
859568
867588
922202
969626
1046670
1054690
1132890
1213593
1274917
1320093
1343909
1422109
1456811
1518461
1596661
1648011
1690328
1733007
1787621
1835045
1877430
1920109
1973524
1997485
2052099
20995...

result:

ok 50 lines

Test #14:

score: 74
Accepted
time: 63ms
memory: 17256kb

input:

50 6500 50
418 1064 27 1257 1065 1780 1067 848 1128 2172 1449 1831 83 905 1662 686 20 1119 1583 910 134 1334 486 1291 93 753 2008 173 2 1483 25 840 1997 1065 259 319 1223 1187 1843 1835 1516 1086 1170 46 1272 889 853 954 1546 1989 704 441 2024 1900 2182 1173 1986 1281 2022 368 1692 174 326 559 1929 ...

output:

14086410
14106056
14135308
14154954
14201539
14206231
14262796
14311786
14390106
14439188
14477348
14528108
14617824
14678548
14721672
14774287
14819398
14867395
14916259
14931630
14983104
15054339
15096589
15104317
15167015
15189371
15233841
15250360
15282739
15332428
15373598
15381326
15439768
154...

result:

ok 50 lines

Test #15:

score: 74
Accepted
time: 104ms
memory: 19476kb

input:

50 8500 50
2446 506 1304 2555 1197 1234 48 427 1621 2080 217 1400 1112 1579 1946 1367 341 1457 1294 556 1039 830 1660 643 338 59 1636 217 1213 958 2405 1536 1451 1881 1676 2231 642 1073 942 379 1588 939 879 1300 1592 571 1333 1911 130 2227 1136 2592 1628 2143 532 1173 2581 257 1718 2395 1939 2516 22...

output:

11051820
11098284
11168256
11234582
11297174
11323554
11410359
11438487
11509524
11555988
11625960
11695508
11741972
11781258
11859066
11896191
11967242
12035842
12082175
12150775
12204151
12268017
12308566
12355030
12415147
12426333
12434423
12480887
12521948
12568412
12623027
12669491
12739463
127...

result:

ok 50 lines