Submission #647602

#TimeUsernameProblemLanguageResultExecution timeMemory
647602ToroTNTravelling Merchant (APIO17_merchant)C++14
Compilation error
0 ms0 KiB
v]#include<bits/stdc++.h> using namespace std; #define ll long long ll n,m,num,b[105][1005],s[105][1005],u_i,v_i,w_i,d[105][105],profit[105][105],dis[105][105],type; int main() { scanf("%lld%lld%lld",&n,&m,&num); for(int i=1;i<=n;i++) { for(int j=1;j<=num;j++) { scanf("%lld%lld",&b[i][j],&s[i][j]); } for(int j=1;j<=n;j++)d[i][j]=1e18; } for(int i=1;i<=n;i++)d[i][i]=0; for(int i=1;i<=m;i++) { scanf("%lld%lld%lld",&u_i,&v_i,&w_i); d[u_i][v_i]=w_i; } for(int k=1;k<=n;k++) { for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { d[i][j]=min(d[i][j],d[i][k]+d[k][j]); } } } for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { for(int k=1;k<=m;k++) { if(b[i][k]!=-1&&s[j][k]!=-1) { profit[i][j]=max(profit[i][j],s[j][k]-b[i][k]); } } } } ll st=0,md,ed=1e9; while(ed>=st) { md=(st+ed)/2; //printf("%lld %lld %lld\n",st,md,ed); for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { if(i==j)dis[i][j]=1e9; else dis[i][j]=d[i][j]*md-profit[i][j]; } } for(int k=1;k<=n;k++) { for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]); } } } type=-1; for(int i=1;i<=n;i++) { if(dis[i][i]<=0) { type=0; } } if(type==0) { st=md+1; }else { ed=md-1; } } printf("%lld",ed); }

Compilation message (stderr)

merchant.cpp:1:3: error: stray '#' in program
    1 | v]#include<bits/stdc++.h>
      |   ^
merchant.cpp:1:1: error: 'v' does not name a type
    1 | v]#include<bits/stdc++.h>
      | ^
merchant.cpp: In function 'int main()':
merchant.cpp:7:5: error: 'scanf' was not declared in this scope
    7 |     scanf("%lld%lld%lld",&n,&m,&num);
      |     ^~~~~
merchant.cpp:28:25: error: 'min' was not declared in this scope; did you mean 'main'?
   28 |                 d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      |                         ^~~
      |                         main
merchant.cpp:40:34: error: 'max' was not declared in this scope
   40 |                     profit[i][j]=max(profit[i][j],s[j][k]-b[i][k]);
      |                                  ^~~
merchant.cpp:64:31: error: 'min' was not declared in this scope; did you mean 'main'?
   64 |                     dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
      |                               ^~~
      |                               main
merchant.cpp:84:5: error: 'printf' was not declared in this scope
   84 |     printf("%lld",ed);
      |     ^~~~~~
merchant.cpp:1:1: note: 'printf' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
  +++ |+#include <cstdio>
    1 | v]#include<bits/stdc++.h>