QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#85892 | #5453. Mana Collection | Appleblue17 | 0 | 870ms | 50716kb | C++14 | 1.3kb | 2023-03-08 20:38:25 | 2023-03-08 20:40:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const long long N=22,M=3e5+5,INF=1e18;
long long n,m,q;
long long v[N],G[N][N];
long long K[M],dp[M][N];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
for(long long i=0;i<n;i++) cin>>v[i];
for(long long i=0;i<n;i++)
for(long long j=0;j<n;j++)
if(i!=j) G[i][j]=INF;
for(long long i=1;i<=m;i++){
long long u,v,w; cin>>u>>v>>w; u--,v--;
G[u][v]=w;
}
for(long long k=0;k<n;k++)
for(long long i=0;i<n;i++)
for(long long j=0;j<n;j++)
G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
for(long long mac=0;mac<(1<<n);mac++){
for(long long i=0;i<n;i++)
if(mac>>i & 1) K[mac]+=v[i];
}
for(long long mac=0;mac<(1<<n);mac++)
for(long long i=0;i<n;i++)
dp[mac][i]=INF;
for(int i=0;i<n;i++) dp[1<<i][i]=0;
for(long long mac=0;mac<(1<<n);mac++){
for(long long i=0;i<n;i++){
if(!(mac>>i & 1) || dp[mac][i]==INF) continue;
cout<<mac<<" "<<i<<": "<<dp[mac][i]<<'\n';
for(long long j=0;j<n;j++){
if((mac>>j & 1) || G[i][j]==INF) continue;
long long nmac=mac | (1<<j);
dp[nmac][j]=min(dp[nmac][j],dp[mac][i]+G[i][j]*K[mac]);
}
}
}
cin>>q;
while(q--){
long long x,u; cin>>x>>u; u--;
long long ans=0;
for(long long mac=0;mac<(1<<n);mac++){
ans=max(ans,K[mac]*x-dp[mac][u]);
}
cout<<ans<<'\n';
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3536kb
input:
2 1 1 10 1 2 10 4 5 1 5 2 100 1 100 2
output:
1 0: 0 2 1: 0 3 1: 10 5 50 100 1090
result:
wrong answer 1st numbers differ - expected: '5', found: '1'
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 3544kb
input:
4 8 50000000 100000000 20000000 70000000 1 2 20 2 1 50 2 3 90 1 3 40 3 1 10 4 1 25 1 4 5 4 3 70 3 8 3 1000000000 1 500000 4
output:
1 0: 0 2 1: 0 3 0: 5000000000 3 1: 1000000000 4 2: 0 5 0: 200000000 5 2: 2000000000 6 1: 600000000 6 2: 9000000000 7 0: 6600000000 7 1: 1600000000 7 2: 11000000000 8 3: 0 9 0: 1750000000 9 3: 250000000 10 1: 3150000000 10 3: 5500000000 11 0: 9750000000 11 1: 4150000000 11 3: 5750000000 12 2: 4550000...
result:
wrong answer 1st numbers differ - expected: '160000000', found: '1'
Test #3:
score: 0
Wrong Answer
time: 3ms
memory: 3612kb
input:
10 90 95677166 99413032 90081107 97391055 96848266 92520734 90623124 96509760 95451402 99152599 1 10 94105173 3 9 91922842 5 2 90862613 8 3 94419460 4 7 90084016 6 4 90693719 10 8 97125103 2 1 93286961 5 10 91546334 4 8 92053784 8 5 96537357 3 1 95913083 1 3 95054163 2 8 95986698 7 6 95233705 8 10 9...
output:
1 0: 0 2 1: 0 3 0: 9273939639075752 3 1: 9031375474821492 4 2: 0 5 0: 8639956692422881 5 2: 9094512932342058 6 1: 8385264523329826 6 2: 9573041938432608 7 0: 26062596877951405 7 1: 26174471782652407 7 2: 27817711729319004 8 3: 0 9 0: 8784107026797285 9 3: 9161668926511790 10 1: 9325521139759020 10 3...
result:
wrong answer 1st numbers differ - expected: '11703326493772984', found: '1'
Test #4:
score: 0
Wrong Answer
time: 4ms
memory: 3608kb
input:
10 90 48104151 45958764 10384927 58976477 4508220 48401738 63414134 56241331 43456656 5364282 4 3 34321182 3 8 6111111 10 3 89336838 7 6 15869517 9 6 45416322 6 8 65416493 8 7 68165563 1 10 17098910 5 7 23144280 10 5 41059929 4 5 83655589 8 2 11141593 10 4 47789741 6 4 15702833 6 5 3119771 9 5 79973...
output:
1 0: 0 2 1: 0 3 0: 2484966424963956 3 1: 857252241349854 4 2: 0 5 0: 363462371620810 5 2: 27325562975550 6 1: 179168071592608 6 2: 2083972532362836 7 0: 3225642088899597 7 1: 1036420312942462 7 2: 2538398863829706 8 3: 0 9 0: 1652706484513119 9 3: 1326509821791837 10 1: 1461122342602251 10 3: 147261...
result:
wrong answer 1st numbers differ - expected: '3586313126541447', found: '1'
Test #5:
score: 0
Wrong Answer
time: 203ms
memory: 3604kb
input:
10 87 61275784 16282886 58999609 52155395 53012427 89533414 15431931 35150033 58505854 59445220 9 5 3496028 7 6 17372183 8 1 287847 2 7 19991219 4 5 40820118 4 9 38405375 1 4 52061958 1 3 95765844 9 7 88432897 10 3 62181295 2 4 2070594 6 8 38490628 5 1 74834920 5 2 58054124 5 10 53052912 9 10 799932...
output:
1 0: 0 2 1: 0 3 0: 337274647319384 3 1: 1944254339008664 4 2: 0 5 0: 1429771213673739 5 2: 1099548783627192 6 1: 2660112126004505 6 2: 403520233813732 7 0: 2227883921453377 7 1: 5246057835420142 7 2: 1729007819729594 8 3: 0 9 0: 975202201574740 9 3: 1823281541583424 10 1: 1732690416672945 10 3: 3371...
result:
wrong answer 1st numbers differ - expected: '18729278111132298', found: '1'
Test #6:
score: 0
Wrong Answer
time: 202ms
memory: 3756kb
input:
10 90 95356560 91592390 93197917 98740065 97680300 92412698 94329246 97243226 90272368 97469569 10 6 99745186 9 3 93877572 4 3 95758698 6 10 91855996 5 1 90121278 5 4 95076290 8 2 99231614 10 3 93399573 4 1 91994993 6 5 94052740 5 2 96068955 2 10 91338395 7 10 91890588 4 7 94880828 1 6 96554961 7 5 ...
output:
1 0: 0 2 1: 0 3 0: 8359766580569900 3 1: 9235777641189840 4 2: 0 5 0: 8447066833649430 5 2: 9007191946967760 6 1: 9214561838717383 6 2: 8659020809281110 7 0: 25407636268568640 7 1: 26709546340280583 7 2: 26018594425597850 8 3: 0 9 0: 9083591588494545 9 3: 9265505048769840 10 1: 9846091103783460 10 3...
result:
wrong answer 1st numbers differ - expected: '163280051600495389', found: '1'
Test #7:
score: 0
Wrong Answer
time: 202ms
memory: 3788kb
input:
10 89 93795458 90122950 90809309 91512557 99759510 98879743 90406791 91988172 98723686 97265654 3 1 92410620 6 10 787488884 1 7 872243221 5 10 93057933 8 3 90945371 7 4 94869387 1 4 90377187 9 1 92060643 10 8 98532700 9 5 97326866 10 2 98947943 1 6 96415500 10 4 92676865 8 7 92985312 9 6 98444476 1 ...
output:
1 0: 0 2 1: 0 3 0: 8710626900079750 3 1: 8599288960762652 4 2: 0 5 0: 8391744546461580 5 2: 9294637086463668 6 1: 8831249161146247 6 2: 8594050160566250 7 0: 25314112392756830 7 1: 25316548463590078 7 2: 26137596614956052 8 3: 0 9 0: 17040081400226108 9 3: 8476969647416646 10 1: 8641263357818446 10 ...
result:
wrong answer 1st numbers differ - expected: '96011873276486328', found: '1'
Test #8:
score: 0
Wrong Answer
time: 213ms
memory: 3596kb
input:
10 89 1382293 67193843 93859961 477481 92652257 99885499 50256117 70192761 34119368 16710544 9 10 42167550 5 8 37587488 6 1 39681485 2 6 83885591 2 8 63502599 2 7 96584704 3 2 28849619 1 2 89615158 7 6 49082361 6 7 6114228 6 10 45456432 7 4 87603741 1 8 8377024 5 9 3400067 10 4 42824742 8 1 34659500...
output:
1 0: 0 2 1: 0 3 0: 3534489070884869 3 1: 32889675579959 4 2: 0 5 0: 4206404641045711 5 2: 24259958177774 6 1: 2400261072061190 6 2: 1307956644184432 7 0: 8525703821851236 7 1: 2459870118846434 7 2: 1367753239101623 8 3: 0 9 0: 17234501459473 9 3: 48800273021808 10 1: 17144216964588 10 3: 21035485437...
result:
wrong answer 1st numbers differ - expected: '5212184985750879', found: '1'
Test #9:
score: 0
Wrong Answer
time: 207ms
memory: 3756kb
input:
10 90 97766575 91352441 94775266 90513638 95828190 90356289 90495007 98680228 93010243 98543991 1 3 99109059 5 8 90074960 6 5 90055463 6 1 90819495 8 9 98346448 8 5 90223065 10 9 92780029 3 6 90250424 9 1 96050114 7 3 90956675 4 2 92037130 4 7 90691071 2 3 91565269 8 3 94131990 2 9 97006947 4 10 942...
output:
1 0: 0 2 1: 0 3 0: 8905476176093179 3 1: 9102747414663100 4 2: 0 5 0: 9226325894770192 5 2: 9689553249902925 6 1: 9266910653951978 6 2: 8364710833971629 7 0: 26484152280100613 7 1: 27153309072581460 7 2: 26419480987718404 8 3: 0 9 0: 8588073998037986 9 3: 9167896616078725 10 1: 8330615467378940 10 3...
result:
wrong answer 1st numbers differ - expected: '8773129927176957', found: '1'
Test #10:
score: 0
Wrong Answer
time: 791ms
memory: 50516kb
input:
18 306 97592575 5845225 97094410 61652068 60514373 77053365 82408570 65859870 52309184 11075991 79663473 60429988 64440299 88087418 51883591 39638284 31941363 95790465 18 7 12121248 13 6 28252098 14 12 2481192 4 16 54868108 13 15 33001477 7 13 15911113 8 16 47075458 7 14 51352052 9 2 41100503 18 10 ...
output:
1 0: 0 2 1: 0 3 0: 55972699709775 3 1: 711918999258025 4 2: 0 5 0: 1846826849850990 5 2: 1530838790523775 6 1: 2555111831579860 6 2: 49048510472250 7 0: 2007057028489515 7 1: 3267030830837885 7 2: 1579887300996025 8 3: 0 9 0: 1058066564157132 9 3: 1161145722166750 10 1: 1065490829489828 10 3: 269060...
result:
wrong answer 1st numbers differ - expected: '56264701460108257', found: '1'
Test #11:
score: 0
Wrong Answer
time: 870ms
memory: 50464kb
input:
18 306 54786856 23623482 37443275 34976477 27052191 21997277 93803298 62986079 72289998 36640646 66962609 75940630 20835955 36012773 32492294 69398349 49378951 13097897 7 10 5470000 8 7 53513890 3 15 38460382 7 16 19142503 5 14 45517218 18 17 42648313 8 18 48305235 4 16 41424027 5 12 52928903 5 4 44...
output:
1 0: 0 2 1: 0 3 0: 314854831152690 3 1: 318587266032536 4 2: 0 5 0: 481455926850625 5 2: 28204711763648 6 1: 198457707350325 6 2: 48691280065998 7 0: 833904434930173 7 1: 517044973382861 7 2: 355221100437794 8 3: 0 9 0: 551666273623638 9 3: 288733798624424 10 1: 85498214226173 10 3: 161028520113720 ...
result:
wrong answer 1st numbers differ - expected: '16448924998323876', found: '1'
Test #12:
score: 0
Wrong Answer
time: 781ms
memory: 50716kb
input:
18 303 87437585 22204459 77335222 63373455 24384957 40111770 61538701 65736765 65450807 20008686 60461910 77184085 62951808 75441264 35010255 67513271 41855413 84760939 6 14 45984925 3 6 5610402 8 1 49203830 8 3 53792394 10 8 11629718 1 12 20708032 4 6 14035635 15 18 487975772 3 1 28292662 3 10 2399...
output:
1 0: 0 2 1: 0 3 0: 174639446711458 3 1: 167227004440050 4 2: 0 5 0: 1007749477740350 5 2: 1024835298514940 6 1: 847055857310102 6 2: 217786529715406 7 0: 1514880647350331 7 1: 1322882414312060 7 2: 1242621828230346 8 3: 0 9 0: 324461886473745 9 3: 407262673846505 10 1: 445665520364895 10 3: 60956191...
result:
wrong answer 1st numbers differ - expected: '1107904896715516', found: '1'
Test #13:
score: 0
Wrong Answer
time: 775ms
memory: 50572kb
input:
18 300 95399651 98514702 95906995 99120696 97373712 99841892 95487998 98629037 97207398 99163728 97816361 94919203 95202846 96133518 98849047 99498436 94447669 96164861 10 8 54922237 1 2 55368382 10 4 54029624 9 8 55267410 14 2 53427574 14 18 54579322 3 9 54230956 2 9 52630731 4 16 53837522 3 7 8372...
output:
1 0: 0 2 1: 0 3 0: 5270962731600852 3 1: 5282124319234682 4 2: 0 5 0: 5041659820884910 5 2: 5028717756070469 6 1: 5202302215277005 6 2: 5250540239817444 7 0: 15470942391643390 7 1: 15405802225071023 7 2: 15492599182744859 8 3: 0 9 0: 5412424150248480 9 3: 5163057636615649 10 1: 5366022283226520 10 3...
result:
wrong answer 1st numbers differ - expected: '109547258785001075', found: '1'
Test #14:
score: 0
Wrong Answer
time: 800ms
memory: 50528kb
input:
18 306 94983318 99500146 99056770 99199070 96785433 94689368 96603811 97464542 96757856 95575432 97758260 96271537 94822391 98897205 96531324 95046283 95759027 99689250 14 18 54518764 3 8 54402270 16 8 52601874 3 11 52679529 13 6 54902169 1 10 54363631 4 2 55268135 5 6 52963284 16 1 52494958 12 11 5...
output:
1 0: 0 2 1: 0 3 0: 5395541284064036 3 1: 5171115232683936 4 2: 0 5 0: 5457791182262930 5 2: 5029041085285896 6 1: 5236776707606630 6 2: 5407174841134356 7 0: 16003816562145486 7 1: 15287245680290768 7 2: 15692774013549444 8 3: 0 9 0: 5265923309906140 9 3: 5196759018844212 10 1: 5482547592634450 10 3...
result:
wrong answer 1st numbers differ - expected: '233314656911878890', found: '1'
Test #15:
score: 0
Time Limit Exceeded
input:
16 240 47666600 44327219 49953274 41785108 32073587 24424080 30939819 78762914 90224099 59998405 64133109 48652631 22221281 96356764 38490560 116991 1 2 91993819 1 3 97619874 1 4 89451708 1 5 79740187 1 6 94041352 1 7 78606419 1 8 126429514 1 9 137890699 1 10 107665005 1 11 111799709 1 12 96319231 1...
output:
1 0: 0 2 1: 0 3 0: 4077830161459361 3 1: 4385032572745400 4 2: 0 5 0: 4876432313767476 5 2: 4653207486008400 6 1: 4709619299684082 6 2: 4179192060638967 7 0: 13382841907956849 7 1: 13856857333326282 7 2: 13058255181018167 8 3: 0 9 0: 3737749279564464 9 3: 4263858784552800 10 1: 3598212883826316 10 3...
result:
Test #16:
score: 0
Time Limit Exceeded
input:
16 240 42361838 31647618 32114308 8782634 17345648 68132951 88405030 26942819 62741100 66985295 20876520 8437021 27114112 66925976 7183979 94977427 2 15 58174648 8 15 34276605 6 10 58212397 2 13 58804593 13 9 54225029 15 14 33719184 11 13 61087050 9 10 28955627 6 2 10289499 10 2 20518981 13 8 837959...
output:
1 0: 0 2 1: 0 3 0: 761195533907196 3 1: 337936521586278 4 2: 0 5 0: 229801798899460 5 2: 1254780559314358 6 1: 383111908488964 6 2: 840640137953562 7 0: 1296904221118432 7 1: 823926390953086 7 2: 2303813362671382 8 3: 0 9 0: 299906118692152 9 3: 844145870852168 10 1: 88664255979404 10 3: 56581928066...
result:
Test #17:
score: 0
Time Limit Exceeded
input:
16 240 94916675 95328982 94461789 98179130 96410042 95984504 99026406 96722757 98043813 97126519 99521857 99735210 99833885 94048501 93989630 97045699 5 6 61339353 7 11 61447467 16 7 59391553 15 5 61958471 13 2 59603541 13 16 60250166 2 3 61615858 16 3 60312774 14 6 61619256 9 2 61767236 7 12 608785...
output:
1 0: 0 2 1: 0 3 0: 5795020598401328 3 1: 5685055415543525 4 2: 0 5 0: 5741863339451193 5 2: 5796408811153275 6 1: 5662388668970355 6 2: 5873777018196556 7 0: 17199713459992139 7 1: 17084728672128665 7 2: 17407204802372231 8 3: 0 9 0: 5759358695665330 9 3: 5859015280483225 10 1: 6003135806410120 10 3...
result:
Test #18:
score: 0
Time Limit Exceeded
input:
17 269 10989016 28905152 56011456 36383994 32588074 40160206 81943847 29653018 81874689 11531228 28812650 79088847 31042740 89163087 58731031 57356809 5076315 2 4 54972232 1 17 48426734 17 8 7126979 7 2 16376090 10 7 30672058 8 17 55225752 2 6 312152706 4 12 1609956 11 10 44726737 7 6 16333848 17 9 ...
output:
1 0: 0 2 1: 0 3 0: 109950168711552 3 1: 100982936158088 4 2: 0 5 0: 1055775225271488 5 2: 186465447665568 6 1: 1349462557020352 6 2: 231893489660032 7 0: 1672470558362560 7 1: 1671472243688584 7 2: 421036531953176 8 3: 0 9 0: 149107756306986 9 3: 100356650158216 10 1: 339590699294886 10 3: 373925052...
result:
Test #19:
score: 0
Time Limit Exceeded
input:
17 241 20878633 21727433 30788417 1919362 24415556 26527489 14285320 3437901 23517959 28616698 11361867 15220890 21496568 20470194 31073215 5981317 11566475 1 2 42606066 1 3 98682648 1 4 22797995 1 5 45294189 1 6 47406122 1 7 35163953 1 8 24316534 1 9 44396592 1 10 49495331 1 11 32240500 1 12 360995...
output:
1 0: 0 2 1: 0 3 0: 925720444408578 3 1: 889556415587778 4 2: 0 5 0: 1590746680559850 5 2: 1158884684726942 6 1: 1616879888909450 6 2: 1141034612313050 7 0: 3854373660055550 7 1: 3792076422885150 7 2: 3127050186733878 8 3: 0 9 0: 43757605279190 9 3: 475990970740835 10 1: 64151841871688 10 3: 78231543...
result:
Test #20:
score: 0
Time Limit Exceeded
input:
17 241 26896510 11416857 23632920 22663714 10426416 1449988 6534437 21431904 6332558 5350871 7478640 7144884 1667707 31989074 24328111 14606283 16379885 1 2 38313367 1 3 50529430 1 4 89019020 1 5 37322926 1 6 28346498 1 7 33430947 1 8 48328414 1 9 33229068 1 10 32247381 1 11 48235649 1 12 34041394 1...
output:
1 0: 0 2 1: 0 3 0: 437418232227519 3 1: 1030495858649170 4 2: 0 5 0: 1262692877645520 5 2: 1359065319289300 6 1: 828328575858840 6 2: 400158291890889 7 0: 2171203545327999 7 1: 3130110572726410 7 2: 2373370828118329 8 3: 0 9 0: 1123218742511936 9 3: 1410996293902000 10 1: 772392314100694 10 3: 38909...
result:
Test #21:
score: 0
Time Limit Exceeded
input:
18 273 5856998 26869251 1761061 23339731 6696975 12073312 26103914 9146585 14284107 2290011 33149581 6690606 1938529 2611081 4180578 15507572 12766646 8196720 1 2 32726249 1 3 7618059 1 4 29196729 1 5 12553973 1 6 17930310 1 7 31960912 1 8 15003583 1 9 20141105 1 10 8147009 1 12 12547604 1 13 779552...
output:
1 0: 0 2 1: 0 3 0: 879329798669499 3 1: 191677574940502 4 2: 0 5 0: 13415866600599 5 2: 44618956326882 6 1: 57247461519570 6 2: 769275039336312 7 0: 987382445340720 7 1: 262726362331290 7 2: 1128640294400190 8 3: 0 9 0: 681443800939899 9 3: 171005183359542 10 1: 1171864133663842 10 3: 14437145198831...
result:
Test #22:
score: 0
Time Limit Exceeded
input:
18 273 18655021 10530209 4072104 27397860 1799797 31844906 10224838 22363503 8387103 25160565 867464 18587455 28492008 3583506 7250222 12947265 13542506 15353338 1 2 29185230 1 3 22727125 1 4 46052881 1 5 20454818 1 6 50499927 1 8 41018524 1 9 44747129 1 10 43815586 1 11 28438355 1 12 37242476 1 13 ...
output:
1 0: 0 2 1: 0 3 0: 325595726053022 3 1: 544451078539830 4 2: 0 5 0: 92547216621000 5 2: 423974994144625 6 1: 66526944425064 6 2: 153765407773417 7 0: 485634000613542 7 1: 755843586984750 7 2: 970622941976820 8 3: 0 9 0: 1261750386234660 9 3: 859117462165501 10 1: 1039147924532340 10 3: 3993904935364...
result:
Test #23:
score: 0
Time Limit Exceeded
input:
18 273 18425031 23650394 24880771 20922906 26575943 17784399 1257646 4304768 2028569 32225860 3162758 23575563 21688821 6218252 30502483 720206 33244851 27314277 1 2 43683269 1 3 61643789 1 4 75113213 1 5 58792271 1 6 52052510 1 7 28904939 1 8 22817172 1 9 26122275 1 11 24226530 1 12 77523542 1 13 6...
output:
1 0: 0 2 1: 0 3 0: 1029166690289778 3 1: 804865585506339 4 2: 0 5 0: 1140064146783474 5 2: 963077457446829 6 1: 1207492802728215 6 2: 1147781173529010 7 0: 3319367068288320 7 1: 3031803144810212 7 2: 2846834978626464 8 3: 0 9 0: 823273187144922 9 3: 885227776940226 10 1: 932602966009800 10 3: 105417...
result:
Test #24:
score: 0
Time Limit Exceeded
input:
18 273 26613501 27441209 12794702 13658897 32546072 2607103 21792275 12508707 8092259 2836952 26658654 15275240 16574454 31623641 1150608 21764569 30050392 12599166 1 2 54054710 1 3 39408203 1 4 40272398 1 5 59159573 1 6 29220604 1 7 48405776 1 9 34705760 1 10 29450453 1 11 53272155 1 12 41888741 1 ...
output:
1 0: 0 2 1: 0 3 0: 1483326594544390 3 1: 1438585078639710 4 2: 0 5 0: 594788258681948 5 2: 1048790249948703 6 1: 605378535884964 6 2: 1104122043056399 7 0: 2780319036575774 7 1: 2724987243468078 7 2: 3613525579330520 8 3: 0 9 0: 550076536225006 9 3: 1071789504445398 10 1: 561382114543082 10 3: 11909...