제출 #409136

#제출 시각아이디문제언어결과실행 시간메모리
409136enerelt14여행하는 상인 (APIO17_merchant)C++14
0 / 100
71 ms1100 KiB
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define ss second #define ff first using namespace std; int n, m, k, b[105][1005], s[105][1005]; vector<pair<int, int> >out[105]; vector<pair<int, int> >in[105]; int patho[105], pathi[105]; void dijkstraa(int s){ bool vis[100005]={0}; priority_queue<pair<int, int> >pq; pq.push(mp(0, s)); while(!pq.empty()){ int u = pq.top().ss; int cost = -pq.top().ff; pq.pop(); patho[u]=cost; vis[u] = 1; for(int i = 0; i < out[u].size(); i++){ int v = out[u][i].ff; int e = out[u][i].ss; if(!vis[v]) pq.push(mp(-(cost + e), v)); } while(!pq.empty() && vis[pq.top().ss]) pq.pop(); } } void dijkstrab(int s){ bool vis[100005]={0}; priority_queue<pair<int, int> >pq; pq.push(mp(0, s)); while(!pq.empty()){ int u = pq.top().ss; int cost = -pq.top().ff; pq.pop(); pathi[u]=cost; vis[u] = 1; for(int i = 0; i < in[u].size(); i++){ int v = in[u][i].ff; int e = in[u][i].ss; if(!vis[v]) pq.push(mp(-(cost + e), v)); } while(!pq.empty() && vis[pq.top().ss]) pq.pop(); } } int main(){ cin>>n>>m>>k; for (int i=1;i<=n;i++)for (int j=1;j<=k;j++)cin>>b[i][j]>>s[i][j]; for (int i=1;i<=m;i++){ int v, w, t; cin>>v>>w>>t; out[v].pb(mp(w, t)); in[w].pb(mp(v, t)); } dijkstraa(1); dijkstrab(1); int res=-INT_MAX; for (int i=2;i<=n;i++){ int p=patho[i]+pathi[i], r=-INT_MAX; for (int j=1;j<=k;j++)r=max(r, s[i][j]-b[1][j]); res=max(res, r/p); } cout<<res; }

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

merchant.cpp: In function 'void dijkstraa(int)':
merchant.cpp:21:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |        for(int i = 0; i < out[u].size(); i++){
      |                       ~~^~~~~~~~~~~~~~~
merchant.cpp: In function 'void dijkstrab(int)':
merchant.cpp:39:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |        for(int i = 0; i < in[u].size(); i++){
      |                       ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...