제출 #874560

#제출 시각아이디문제언어결과실행 시간메모리
874560amogususus여행하는 상인 (APIO17_merchant)C++17
0 / 100
46 ms2260 KiB
#pragma GCC optimize("O2,unroll-loops,inline") #pragma GCC target("avx2,bmi,bmi2,popcnt") #include<bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define endl '\n' #define all(x) x.begin(),x.end() #define pll pair<ll,ll> #define plll pair<pll,pll> #define open(name) if(fopen(name".inp", "r")){freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);} using namespace std; const int maxN=102; const int mod=998244353; const ll inf = 72340172838076673; ll n,m,k,a[maxN][1002],b[maxN][1002],d[maxN][maxN],c[maxN][maxN],dis[maxN][maxN]; vector<pll> adj[maxN]; void dijkstra(ll s){ priority_queue<pll,vector<pll>,greater<pll>> pq; memset(d[s],1,sizeof d[s]); pq.push({0,s});d[s][s]=0; while(!pq.empty()){ ll dist=pq.top().first,u=pq.top().second;pq.pop(); if(d[s][u]<dist)continue; for(auto x:adj[u]){ ll v=x.first,w=x.second; if(d[s][v]>d[s][u]+w)d[s][v]=d[s][u]+w,pq.push({d[s][v],v}); } } } bool check(ll x){ for(int i=1;i<=n;i++)for(int j=1;j<=n;j++) if(i!=j&&d[i][j]!=inf)dis[i][j]=x*d[i][j]-c[i][j]; else dis[i][j]=inf; 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]); for(int i=1;i<=n;i++)if(dis[i][i]<=0)return 1; return 0; } void Enter(){ cin>>n>>m>>k; for(int i=1;i<=n;i++)for(int j=1;j<=k;j++)cin>>a[i][j]>>b[i][j]; for(int i=1;i<=m;i++){ ll u,v,w;cin>>u>>v>>w; adj[u].pb({v,w}); } for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)for(int z=1;z<=k;z++)c[i][j]=max(c[i][j],b[j][k]-a[i][k]); for(int i=1;i<=n;i++)dijkstra(i); ll l=0,r=1e10+2; while(l<r){ ll mid=l+r>>1; if(check(mid))l=mid+1; else r=mid; } cout<<l-1; } //amogus signed main(){ //open("tbrackets"); cin.tie(nullptr);ios_base::sync_with_stdio(NULL); //ll t=1;cin>>t;while(t--) Enter(); }

컴파일 시 표준 에러 (stderr) 메시지

merchant.cpp: In function 'void Enter()':
merchant.cpp:51:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   51 |         ll mid=l+r>>1;
      |                ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...