이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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=0;
for (int i=2;i<=n;i++){
int p=patho[i]+pathi[i], r=0;
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |