QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#538349 | #8319. Emiya 家明天的饭 | yanshanjiahong | 40 | 433ms | 78628kb | C++20 | 1.3kb | 2024-08-31 10:44:00 | 2024-08-31 10:44:00 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define ls(x) (x<<1)
#define rs(x) ((x<<1)|1)
#define mp make_pair
#define sec second
#define fir first
#define pii pair<int,int>
#define lowbit(i) i&-i
using namespace std;
typedef long long ll;
const int N=22,M=1e6+5,S=(1<<20)+5,inf=2e9+7,mo=998244353;
void read(int &p){
int x=0,w=1;
char ch=0;
while(!isdigit(ch)){
if(ch=='-')w=-1;
ch=getchar();
}
while(isdigit(ch)){
x=(x<<1)+(x<<3)+ch-'0';
ch=getchar();
}
p=x*w;
}
int n,m;
int a[N][M];
ll f[S][N];
signed main(){
read(n),read(m);
rep(i,1,n){
rep(j,1,m)
read(a[i][j]);
}
rep(i,1,m){
int st=0;
rep(j,1,n)
if(a[j][i]==-1)st|=(1<<(j-1));
rep(j,1,n)
if(a[j][i]!=-1)f[st][j]+=a[j][i];
}
int tot=(1<<n)-1;
rep(i,1,n){
rep(j,1,n){
int nwv=(1<<(j-1));
for(int k=nwv;k<=tot;k+=nwv<<1){
rep(l,0,nwv-1)
f[k+l][i]+=f[k+l-nwv][i];
}
}
}
ll ans=0;
rep(st,0,tot){
ll res=0;
rep(i,1,n){
if((st>>(i-1))&1)continue;
res+=f[st][i];
}
ans=max(ans,res);
}
printf("%lld\n",ans);
return 0;
}
詳細信息
Subtask #1:
score: 20
Accepted
Test #1:
score: 20
Accepted
time: 2ms
memory: 24380kb
input:
10 2000 577534 -1 -1 1510473 1954923 -1 3088519 -1 9958770 -1 -1 789229936 7476647 -1 -1 -1 -1 -1 8959559 -1 -1 8222549 2329485 -1 -1 -1 -1 -1 9438768 -1 5521504 -1 -1 -1 -1 -1 -1 8497790 1061851 9092355 7487890 5950767 7099280 4539854 -1 873314 -1 2079774 4461992 681211 -1 -1 -1 9453031 -1 -1 31860...
output:
144921545910
result:
ok 1 number(s): "144921545910"
Test #2:
score: 20
Accepted
time: 0ms
memory: 24604kb
input:
10 1981 36854 -1 -1 -1 58589 365339 -1 -1 -1 -1 -1 -1 -1 -1 -1 13451 -1 -1 378380 -1 -1 105086 348305 -1 -1 142112 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 70791 -1 -1 357983 -1 127530 -1 -1 -1 -1 -1 -1 717177876 -1 -1 -1 -1 -1 -1 -1 -1 -1 85569 -1 -1 -1 -1 319836 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...
output:
143781283794
result:
ok 1 number(s): "143781283794"
Test #3:
score: 20
Accepted
time: 0ms
memory: 26532kb
input:
10 1980 -1 -1 -1 -1 212643 125070 -1 2384112 -1 1083667 929176 -1 966102 -1 -1 -1 2282563 -1 1517526 1857317 -1 -1 -1 949372 -1 -1 -1 1919723 -1 -1 571990 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 414879 -1 -1 -1 -1 -1 1548061 -1 -1 -1 211579 -1 317755 -1 2253398 -1 1342148 -1 -1 1846907 -1 -1 -1 161059 2014...
output:
135858523900
result:
ok 1 number(s): "135858523900"
Test #4:
score: 20
Accepted
time: 0ms
memory: 24484kb
input:
10 1977 -1 5079259 5207799 1469061 6112915 -1 1937995 -1 2679781 -1 5237215 -1 4588981 6700093 7443852 5890076 -1 4785134 6615436 -1 6170584 -1 -1 -1 -1 -1 8034785 -1 -1 -1 7613414 -1 -1 4302759 4953012 -1 677643 6979231 6603668 9154773 7721719 728934 -1 -1 5304117 -1 2969285 -1 -1 -1 -1 5048218 -1 ...
output:
152900832222
result:
ok 1 number(s): "152900832222"
Test #5:
score: 20
Accepted
time: 0ms
memory: 24468kb
input:
10 1966 191182 3542353 -1 1449491 1918173 -1 521607060 -1 404200 2592966 -1 3157674 1764430 1169543 291226 -1 -1 3414911 2816172 -1 1155424 1877374 -1 362214 2017417 1951302 363494 3208779 1285214 1021340 -1 2352176 -1 2109275 -1 2982958 -1 510425436 2610010 3583665 -1 -1 1498259 -1 -1 -1 2509123 -1...
output:
133379948003
result:
ok 1 number(s): "133379948003"
Test #6:
score: 20
Accepted
time: 5ms
memory: 24464kb
input:
10 2000 -1 -1 -1 8676752 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8950050 -1 -1 5047530 -1 -1 -1 -1 -1 -1 -1 -1 3596456 -1 -1 -1 -1 5644804 1285133 -1 -1 -1 1993454 -1 515091 -1 2031387 -1 -1 -1 260858 -1 -1 -1 5634739 -1 -1 -1 -1 4140488 -1 -1 7499368 -1 -1 4223049 -1 -1 -1 -1 -1 -1 8515336 292...
output:
88272613721
result:
ok 1 number(s): "88272613721"
Test #7:
score: 20
Accepted
time: 0ms
memory: 24408kb
input:
10 1957 -1 -1 -1 9258822 5042715 -1 5655856 -1 -1 -1 -1 5999144 -1 3886842 102480 -1 -1 -1 -1 3971400 1305044 1923125 2173799 7508660 62893 6471290 3568831 -1 -1 -1 -1 -1 -1 -1 1508641 2989329 8201935 3611211 819952157 -1 -1 7426076 7243997 4059260 9010620 9422058 -1 -1 5005478 -1 -1 -1 -1 3901931 -...
output:
152846234928
result:
ok 1 number(s): "152846234928"
Test #8:
score: 20
Accepted
time: 0ms
memory: 24444kb
input:
10 2000 378530 1045009 246082 -1 208242 4289571 4835797 2576660 -1 4416431 -1 689375 1314926 -1 -1 4610822 -1 4169735 -1 -1 -1 2654630 3283410 4474333 -1 2369066 -1 3466683 1335332 3818665 474639 1390456 3288233 -1 3435379 2859743 3965183 1120511 -1 884011 -1 3914697 3701748 4252926 3433721 -1 11999...
output:
125541101976
result:
ok 1 number(s): "125541101976"
Test #9:
score: 20
Accepted
time: 0ms
memory: 22340kb
input:
9 1993 -1 56347 739534 -1 -1 -1 -1 326395 -1 227069 -1 436937 -1 -1 382924 1026500 135915 255758 -1 588439728 254549 -1 477098 -1 631568 993709 129499 194238 -1 -1 180370 456426 -1 631788 -1 -1 318418 56941 450496 750006 1021723 -1 735611 -1 36273 298461 313880 -1 -1 -1 538658 741309 -1 -1 506445 29...
output:
137551454390
result:
ok 1 number(s): "137551454390"
Test #10:
score: 20
Accepted
time: 0ms
memory: 20228kb
input:
8 2000 5899593 8169541 -1 -1 -1 -1 -1 8013793 7032240 -1 8358173 1239485 -1 4001022 -1 -1 412779 971598 3920348 2190856 8485141 2854457 7123379 -1 -1 7800012 3694457 -1 1448931 8963790 924865 2416364 5419218 -1 4368480 76137 1262253 -1 -1 4617253 -1 9396462 -1 8118842 4296674 -1 -1 -1 -1 -1 -1 55106...
output:
90782422398
result:
ok 1 number(s): "90782422398"
Subtask #2:
score: 20
Accepted
Dependency #1:
100%
Accepted
Test #11:
score: 20
Accepted
time: 356ms
memory: 53580kb
input:
12 999842 8351128 8274172 7778980 -1 -1 -1 867914 8667911 5064647 734974899 8728096 -1 -1 -1 -1 9260101 9170550 -1 -1 3918380 -1 5516927 -1 -1 1497260 3234767 4467407 4260505 -1 -1 3049312 1035780 -1 -1 -1 -1 3160955 9642578 -1 -1 -1 8401788 -1 -1 -1 8123208 -1 5891916 9598028 -1 -1 7250111 -1 17075...
output:
5471074751111
result:
ok 1 number(s): "5471074751111"
Test #12:
score: 20
Accepted
time: 358ms
memory: 64228kb
input:
14 999255 -1 -1 -1 -1 447334 403041 -1 -1 -1 -1 311256 452465 -1 10722 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 238316 -1 -1 -1 -1 -1 -1 -1 -1 27807 -1 438516 -1 133297 -1 -1 30352 150327 -1 -1 288218 -1 -1 -1 354085 -1 368563 -1 -1 -1 420125 345869 409737 -1 -1 -1 -1 -1 -1 -1 116981 -1 44...
output:
9187420681227
result:
ok 1 number(s): "9187420681227"
Test #13:
score: 20
Accepted
time: 328ms
memory: 64216kb
input:
14 1000000 27376 255265 -1 77973 17150 22178 43524 112893 19015 219489 -1 -1 54402 -1 -1 -1 -1 -1 243886 154846 150638 60294 -1 105043 183646 -1 -1 95917 19201 -1 -1 -1 -1 65556 -1 202356 39105 221523 -1 183588 39274 -1 -1 249820 123770 62946 217459 -1 94444 -1 124223 -1 -1 -1 129031 -1 25863 170451...
output:
1984210288399
result:
ok 1 number(s): "1984210288399"
Test #14:
score: 20
Accepted
time: 429ms
memory: 65368kb
input:
14 999836 2664220 8393524 -1 8447950 -1 7673778 1970642 751040 -1 1238798 -1 -1 9501482 1312805 -1 5174533 -1 -1 -1 3605783 8422103 -1 647871 3050793 7623676 9983715 -1 -1 -1 5670146 -1 -1 -1 9916783 2347596 -1 591641 2510503 -1 2415638 -1 9862480 -1 1143735 3363125 8803317 4821233 945135 6484824 -1...
output:
3746845955363
result:
ok 1 number(s): "3746845955363"
Test #15:
score: 20
Accepted
time: 358ms
memory: 65004kb
input:
14 1000000 -1 -1 -1 -1 46846 -1 122011 156782 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 122043 155220 -1 114399 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 183458 -1 -1 -1 -1 -1 -1 183432 -1 -1 -1 -1 -1 70084 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
output:
9701660447593
result:
ok 1 number(s): "9701660447593"
Test #16:
score: 20
Accepted
time: 347ms
memory: 64340kb
input:
14 1000000 72231 71333 -1 23482 -1 -1 -1 -1 14078 96039 222274 29281 63850 170473 228127 -1 82543 -1 -1 -1 -1 -1 -1 -1 33916 -1 36092 129778 -1 100386 22607 191358 -1 -1 -1 -1 -1 127872 186093 108767 -1 5102 -1 -1 127078 87675 -1 54537 255892 89684 -1 -1 -1 68638 110374 -1 -1 -1 -1 30748 55603 -1 -1...
output:
3003093266284
result:
ok 1 number(s): "3003093266284"
Test #17:
score: 20
Accepted
time: 348ms
memory: 55568kb
input:
12 999161 -1 5917388 -1 -1 -1 -1 3895488 88301 -1 -1 -1 -1 -1 1244422 -1 -1 -1 3268890 -1 1557772 8567456 -1 -1 1634516 -1 9103009 -1 3424735 -1 7820320 -1 -1 3020370 -1 8418003 -1 -1 3519227 -1 -1 -1 -1 7191450 -1 -1 -1 5503709 -1 -1 6439154 9724423 2248187 -1 -1 679111 -1 -1 3536275 -1 -1 -1 -1 -1...
output:
5053614418856
result:
ok 1 number(s): "5053614418856"
Test #18:
score: 20
Accepted
time: 344ms
memory: 65228kb
input:
14 999742 -1 122262 322968 -1 414280 -1 375812 -1 -1 -1 -1 -1 265869 -1 -1 -1 -1 -1 -1 -1 -1 84711 -1 378336 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 405399 -1 -1 -1 -1 322360 -1 -1 -1 359363 50561 -1 21121 -1 -1 -1 -1 -1 80430 70006 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 320455 62295 -1 -1 -1 -1 -1 -1 -1 -...
output:
9219310271446
result:
ok 1 number(s): "9219310271446"
Test #19:
score: 20
Accepted
time: 330ms
memory: 62416kb
input:
14 1000000 265317 215412 159375 20642 86441 -1 386467 74834 68219 -1 -1 108132 -1 -1 -1 66892 61016 -1 -1 -1 -1 398745 -1 -1 -1 -1 -1 -1 -1 -1 -1 355440 153278 167113 -1 -1 325866 315718 297268 -1 -1 -1 44111 82016 -1 -1 -1 312522 91306 -1 -1 -1 -1 -1 -1 -1 -1 225083 313396 -1 -1 -1 -1 -1 17097 -1 2...
output:
2075287371388
result:
ok 1 number(s): "2075287371388"
Test #20:
score: 20
Accepted
time: 433ms
memory: 65488kb
input:
14 1000000 -1 4014659 -1 1406557 4498551 -1 -1 -1 8463382 5125618 4343590 -1 -1 -1 -1 -1 4399355 3459304 -1 7900765 -1 7428917 -1 1012616 3541798 -1 -1 -1 -1 -1 -1 2212556 3733085 1319013 3077590 7627542 5840654 -1 8617766 -1 4916116 -1 3101285 -1 -1 5222593 -1 -1 -1 7304218 4167369 3959677 -1 -1 -1...
output:
4145165034293
result:
ok 1 number(s): "4145165034293"
Subtask #3:
score: 0
Time Limit Exceeded
Test #21:
score: 20
Accepted
time: 309ms
memory: 78628kb
input:
16 1000000 1678292 3506611 3517442 7482059 3235169 7850879 2719736 3579860 8212996 8672372 7235114 6351463 6539238 3596242 517079 6853239 6033392 9054320 7042766 9890810 8455403 8916458 9785849 1807102 1412966 4281493 8750874 8326572 5481267 7653917 40034 4405576 1523421 3568949 6846331 5491786 3132...
output:
22206120770174
result:
ok 1 number(s): "22206120770174"
Test #22:
score: 0
Time Limit Exceeded
input:
20 999337 7962 261862 394368 84978 371886 390829 229413 258152 151076 272803 50841 261776 294476 17549 355384 315013 250559 191181 239307 184740 336467 110808 296673 282182 397701 34348 322548 273854 129328 347816 231304 127903 151033 247944 352320 130954 235267 86998 122532 370648 73642 230206 1213...
output:
12054261506588
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
0%