QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#410058 | #676. Travelling Merchant | AhmedSolyman# | 33 | 565ms | 5656kb | C++20 | 2.0kb | 2024-05-13 09:25:59 | 2024-05-13 09:26:00 |
Judging History
answer
/*
In the name of Allah
made by: Ahmed_Solyman
*/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//-------------------------------------------------------------//
typedef long long ll;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define all(v) v.begin(),v.end()
int main(){
fast
int n,m,k;cin>>n>>m>>k;
vector<vector<ll>>a(n+1,vector<ll>(k+1));
vector<vector<ll>>b(n+1,vector<ll>(k+1));
for(int i=1;i<=n;i++){
for(int j=1;j<=k;j++){
cin>>a[i][j]>>b[i][j];
}
}
vector<vector<ll>>dist(n+5,vector<ll>(n+5,4e18));
vector<vector<bool>>vis(n+5,vector<bool>(n+5));
for(int i=0;i<m;i++){
int u,v,w;cin>>u>>v>>w;
dist[u][v]=w;
vis[u][v]=1;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
for(int k=1;k<=n;k++){
dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
}
}
}
ll l=1,r=1e18,ans=0;
while(l<=r){
ll mid=(l+r)>>1LL;
vector<vector<ll>>dist2(n+5,vector<ll>(n+5,4e18));
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
dist2[i][j]=mid*min((ll)4e18/mid,dist[i][j]);
ll mx=0;
for(int h=1;h<=k;h++){
if((~a[i][h]) && (~b[j][h])){
mx=max(mx,b[j][h]-a[i][h]);
}
}
dist2[i][j]-=mx;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
for(int k=1;k<=n;k++){
dist2[i][j]=min(dist2[i][j],dist2[i][k]+dist2[k][j]);
}
}
}
bool v=0;
for(int i=1;i<=n;i++){
if(dist2[i][i]<=0)v=1;
}
if(v){
ans=mid;
l=mid+1;
}
else{
r=mid-1;
}
}
cout<<ans<<endl;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 12
Accepted
time: 293ms
memory: 5356kb
input:
100 181 1000 553730496 158361961 892706912 178296397 743382683 297380306 641674485 99624440 917350062 18856036 844421978 187895310 648680590 312745394 560991872 402321479 712754581 166489560 776432653 57402415 554268728 511597509 861517186 541462029 843246768 457630601 923371196 521104850 557772066 ...
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 35ms
memory: 4044kb
input:
100 100 1 1 1 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 100...
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 35ms
memory: 3840kb
input:
100 100 1 1 1 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 -1 100...
output:
9999999
result:
ok single line: '9999999'
Test #4:
score: -12
Wrong Answer
time: 5ms
memory: 3648kb
input:
50 98 1 294990003 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 481362725 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...
output:
0
result:
wrong answer 1st lines differ - expected: '1968', found: '0'
Subtask #2:
score: 0
Wrong Answer
Test #14:
score: 0
Wrong Answer
time: 6ms
memory: 3660kb
input:
50 50 20 1000000000 94476 1000000000 75837 1000000000 27079 1000000000 129004 1000000000 100830 1000000000 98560 1000000000 99302 1000000000 65993 30410 1 1000000000 66183 1000000000 89148 1000000000 21236 1000000000 11935 1000000000 53895 1000000000 126490 1000000000 104741 1000000000 78615 1000000...
output:
981
result:
wrong answer 1st lines differ - expected: '1003', found: '981'
Subtask #3:
score: 33
Accepted
Test #37:
score: 33
Accepted
time: 564ms
memory: 5588kb
input:
100 243 1000 969713863 380451398 977287381 546839551 578242281 267067963 834635238 316438277 806980243 189648353 779415475 453867771 741678190 352485450 473763928 190177433 687118672 377243148 644333594 197290749 949048287 436673078 690006797 180711316 714366028 387342721 980055654 198167471 8873988...
output:
28
result:
ok single line: '28'
Test #38:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
5 7 4 727218133 319808016 451811473 341827334 983666612 208956608 712124347 20325770 625539547 511168571 950094471 396282690 649119245 412489786 504515934 498965733 955685647 120970424 900386157 487638774 666900039 254430876 841869836 23162184 670731166 282497058 791738936 425566820 916482877 602671...
output:
8
result:
ok single line: '8'
Test #39:
score: 0
Accepted
time: 14ms
memory: 3728kb
input:
50 100 100 738055508 380547266 466519731 321379362 627164749 501738148 790388363 534474035 594031599 289323442 585921101 400847039 988432406 326676078 973287243 480408179 677194803 254403874 960518968 523054718 490930760 258858830 532158736 498097146 823424101 17095805 770242306 523332445 830717940 ...
output:
138919
result:
ok single line: '138919'
Test #40:
score: 0
Accepted
time: 17ms
memory: 3800kb
input:
50 100 100 714420219 664420219 670988077 620988077 749695455 699695455 567602634 546701549 630315751 580315751 548562478 510475293 734437437 684437437 517242293 467242293 712844065 662844065 530370481 480370481 584518044 534518044 780621679 730621679 542815120 533903899 599496563 549496563 709776870...
output:
2773
result:
ok single line: '2773'
Test #41:
score: 0
Accepted
time: 17ms
memory: 3732kb
input:
50 80 100 613124154 298784098 537389012 279713205 499689681 471314836 886103757 60087694 845068143 368855914 648389008 300242966 646640622 221676660 866330078 514509030 604069994 416492438 611394991 453739552 732469971 524033149 694292198 5271026 573810521 471002300 531489460 212864274 881123884 266...
output:
49797
result:
ok single line: '49797'
Test #42:
score: 0
Accepted
time: 565ms
memory: 5656kb
input:
100 9900 1000 986355298 343941451 748009505 157768582 549897631 353675832 784259651 71183802 455272137 239882644 688026841 125591164 861653505 535779783 761535420 360625660 485161701 275682287 548652543 525094271 577374254 540601357 586092427 379551990 490170545 79852082 804653532 513745338 55248752...
output:
2478
result:
ok single line: '2478'
Test #43:
score: 0
Accepted
time: 561ms
memory: 5436kb
input:
100 9900 1000 727914573 352681283 745159911 478069159 524736757 267716315 554533162 49659853 704220141 272866726 878406576 349556214 606558787 31608223 752128450 136602787 645580703 226343143 981500098 238380602 863321669 443495332 937077574 118463117 609547732 88002197 787077169 405900536 776842331...
output:
1330867
result:
ok single line: '1330867'
Test #44:
score: 0
Accepted
time: 84ms
memory: 4036kb
input:
100 100 100 289207 289207 384956 384956 229259 229259 546415 546415 171739 171739 282850 282850 221135 221135 16583 16583 370773 370773 119341 119341 426085 426085 440159 440159 253180 253180 529005 529005 428704 428704 211778 211778 309906 309906 325591 325591 156929 156929 288408 288408 422082 422...
output:
830
result:
ok single line: '830'
Test #45:
score: 0
Accepted
time: 509ms
memory: 5280kb
input:
100 500 900 370608755 370608755 394298561 394298561 477985939 477985939 312239957 312239957 742647608 742647608 346481586 346481586 535875402 535875402 711205883 711205883 538460115 538460115 399559367 399559367 716685729 716685729 631088306 631088306 420575105 420575105 418270029 418270029 45272598...
output:
2936107
result:
ok single line: '2936107'
Test #46:
score: 0
Accepted
time: 54ms
memory: 3912kb
input:
100 563 40 490783053 490783053 500616737 500616737 610816964 610816964 630654725 630654725 605493528 605493528 374238654 374238654 452823555 452823555 519705766 519705766 537548608 537548608 447518535 447518535 524316798 524316798 551017738 551017738 662639933 662639933 574991144 574991144 505436345...
output:
2420209
result:
ok single line: '2420209'
Test #47:
score: 0
Accepted
time: 84ms
memory: 4000kb
input:
100 100 100 1 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000000...
output:
100
result:
ok single line: '100'
Test #48:
score: 0
Accepted
time: 85ms
memory: 3888kb
input:
100 100 100 1 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000000...
output:
999999999
result:
ok single line: '999999999'
Test #49:
score: 0
Accepted
time: 49ms
memory: 3916kb
input:
100 596 40 358458945 358458945 331034157 331034157 349074033 349074033 344044690 344044690 485167401 485167401 734094465 734094465 530915559 530915559 589250413 589250413 256795508 256795508 489343536 489343536 534470289 534470289 267233079 267233079 482426953 482426953 626623725 626623725 648411549...
output:
2394068
result:
ok single line: '2394068'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%