이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >
#define fi first
#define se second
#define fr front()
#define pb push_back
#define t top()
#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)
#define oo 1e18
#define eps 1e-8
#define pow poww
#define int long long
const int N = 1e5 + 5;
int n , m , s , e , u , v;
int S[N] , E[N] , V[N] , U[N] , A[N];
vector < int > C;
vector < ii > g[N];
priority_queue < ii , vector < ii > , greater < ii > > q;
void dijk(int u , int dist[])
{
FOR(i , 1 , n)
dist[i] = oo;
dist[u] = 0;
q.push(ii(0 , u));
while(!q.empty())
{
int val = q.t.fi;
int u = q.t.se;
q.pop();
if(val > dist[u])
continue;
REP(s , g[u].size())
{
int v = g[u][s].fi;
int cost = g[u][s].se;
if(dist[v] > dist[u] + cost)
q.push(ii(dist[v] = dist[u] + cost , v));
}
}
}
main()
{
//freopen("E.inp","r",stdin);
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
cin >> s >> e;
cin >> u >> v;
FOR(i , 1 , m)
{
int u , v , c;
cin >> u >> v >> c;
g[u].pb(ii(v , c));
g[v].pb(ii(u , c));
}
dijk(s , S);
dijk(e , E);
dijk(u , U);
dijk(v , V);
int cnt = 0;
int res = U[v];
FOR(i , 1 , n)
if(V[i] <= V[u])
C.pb(i);
//cout << V[1] << " " << V[6] << endl;
REP(s , C.size())
{
int a = C[s];
cnt += n;
dijk(a , A);
FOR(b , 1 , n)
{
if(S[a] + A[b] + E[b] == S[e] || S[b] + A[b] + E[a] == S[e])
res = min(res , min(U[a] + V[b] , U[b] + V[a]));
}
if(cnt >= 2000000)
break;
}
cout << res;
}
컴파일 시 표준 에러 (stderr) 메시지
commuter_pass.cpp: In function 'void dijk(long long int, long long int*)':
commuter_pass.cpp:16:38: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | #define REP(i , n) for(int i = 0 ; i < n ; ++i)
......
44 | REP(s , g[u].size())
| ~~~~~~~~~~~~~~~
commuter_pass.cpp:44:9: note: in expansion of macro 'REP'
44 | REP(s , g[u].size())
| ^~~
commuter_pass.cpp: At global scope:
commuter_pass.cpp:54:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
54 | main()
| ^
commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:16:38: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | #define REP(i , n) for(int i = 0 ; i < n ; ++i)
......
81 | REP(s , C.size())
| ~~~~~~~~~~~~
commuter_pass.cpp:81:5: note: in expansion of macro 'REP'
81 | REP(s , C.size())
| ^~~
# | 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... |