이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "escape_route.h"
#include <queue>
#include <utility>
#include <stdio.h>
#define ll long long
using namespace std;
struct aaa
{
ll a,b,c;
};
priority_queue < pair < ll , ll > , vector < pair < ll , ll > >, greater < pair < ll , ll > > > dij;
vector < long long > Ans;
pair < long long , long long > DP[105][105];
vector < aaa > Next[105];
ll vis[105];
pair < ll, ll > operator +(pair < ll , ll > a, pair < ll , ll > b)
{
b.first+=a.first;
if(b.second==0) b.second=a.second;
else if(a.second&&b.second) b.first++;
return b;
}
vector<long long> calculate_necessary_time(int N, int M, long long S, int Q,vector<int> A,vector<int> B,vector<long long> L,vector<long long> C,vector<int> U,vector<int> V,vector<long long> T)
{
//printf("aaaaa\n");
ll i,j,k,a,b,c;
pair < ll , ll > ans;
aaa tt;
for(i=0;i<M;i++)
{
tt.a=B[i];
tt.b=L[i];
tt.c=C[i];
Next[A[i]].push_back(tt);
tt.a=A[i];
Next[B[i]].push_back(tt);
}
for(i=0;i<N;i++) for(j=0;j<N;j++) DP[i][j]=make_pair(100,0);
for(i=0;i<N;i++)
{
DP[i][i]=make_pair(0,0);
vis[i]=-1;
}
for(i=0;i<N;i++)
{
dij.push(make_pair(0,i));
while(!dij.empty())
{
auto xx=dij.top();
dij.pop();
a=xx.first;
b=xx.second;
if(vis[b]==i) continue;
vis[b]=i;
DP[i][b]=make_pair(0,a);
for(auto j:Next[b]) if(a+j.b<=j.c) dij.push(make_pair(a+j.b,j.a));
}
}
for(k=0;k<N;k++) for(i=0;i<N;i++) for(j=0;j<N;j++) DP[i][j]=min(DP[i][j],DP[i][k]+DP[k][j]);
for(i=0;i<N;i++) vis[i]=-1;
for(i=0;i<Q;i++)
{
ans=make_pair(100,0);
dij.push(make_pair(T[i],U[i]));
while(!dij.empty())
{
auto xx=dij.top();
dij.pop();
a=xx.first;
b=xx.second;
//printf("%lld %lld %lld\n",a,b,vis[b]);
if(vis[b]==i) continue;
vis[b]=i;
//printf("bb %lld %lld %lld %lld\n",b,a,DP[b][V[i]].first,DP[b][V[i]].second);
//if(b==V[i]) ans=min(ans,make_pair((ll) 0,a));
ans=min(ans,make_pair(0,a)+DP[b][V[i]]);
for(auto j:Next[b]) if(a+j.b<=j.c&&vis[j.a]!=i) dij.push(make_pair(a+j.b,j.a));
}
//printf("aa %lld %lld %lld\n",ans.first,ans.second,T[i]);
Ans.push_back(ans.first*S+ans.second-T[i]);
//`printf("aa %lld\n",Ans[i]);
}
return Ans;
}
컴파일 시 표준 에러 (stderr) 메시지
escape_route.cpp: In function 'std::vector<long long int> calculate_necessary_time(int, int, long long int, int, std::vector<int>, std::vector<int>, std::vector<long long int>, std::vector<long long int>, std::vector<int>, std::vector<int>, std::vector<long long int>)':
escape_route.cpp:27:18: warning: unused variable 'c' [-Wunused-variable]
27 | ll i,j,k,a,b,c;
| ^
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |