이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* Author: Amirrrr
* Created: 24.06.2023
* Why am I so stupid? :c
* Slishkom slab
**/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define FF first
#define SS second
#define ent "\n"
#define int long long
const int N = 2e5 + 13;
const int MOD = 1e9 + 7;
const int INF = 1e18;
int n,m,s,t,u,v,pr[N],ans[N],ans1[N];
vector<pair<int,int>>g[N];
void gogo (){
cin>>n>>m;
cin>>s>>t>>u>>v;
map<pair<int,int>,int>mp;
for(int i=1;i<=m;i++){
int x,y,val;cin>>x>>y>>val;
g[x].pb({y,val}),g[y].pb({x,val});
mp[{x,y}]=val;
mp[{y,x}]=val;
}
for(int i=1;i<=n;i++)ans[i]=INF,ans1[i]=INF;
set<pair<int,int>>st;
vector<int>dst;
st.insert({0,s});
ans[s]=0;
while(st.size()){
pair<int,int>v=*(st.begin());
st.erase(st.begin());
for(auto to:g[v.SS]){
int cur=ans[v.SS]+mp[{to.FF,v.SS}];
if(ans[to.FF]>cur){
ans[to.FF]=cur;
st.erase({ans[to.FF],to.FF});
st.insert({cur,to.FF});
pr[to.FF]=v.SS;
}
}
}
int ok=t;
while(ok){
dst.pb(ok);
ok=pr[ok];
}
for(int i=0;i+1<dst.size();i++){
mp[{dst[i],dst[i+1]}]=0,mp[{dst[i+1],dst[i]}]=0;
}
st.insert({0,u});
ans1[u]=0;
while(st.size()){
pair<int,int>v=*(st.begin());
st.erase(st.begin());
for(auto to:g[v.SS]){
int cur=ans1[v.SS]+mp[{to.FF,v.SS}];
if(ans1[to.FF]>cur){
ans1[to.FF]=cur;
st.erase({ans1[to.FF],to.FF});
st.insert({cur,to.FF});
}
}
}
cout<<ans1[v];
}
signed main (/*Amir Mirmanov*/){
ios_base::sync_with_stdio(0),cin.tie(0);
int Q = 1,test = 1;
//freopen("herding.in","r",stdin);
//freopen("herding.out","w",stdout);
// cin >> Q;
while (Q --){
gogo ();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
commuter_pass.cpp: In function 'void gogo()':
commuter_pass.cpp:59:20: 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]
59 | for(int i=0;i+1<dst.size();i++){
| ~~~^~~~~~~~~~~
commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:81:15: warning: unused variable 'test' [-Wunused-variable]
81 | int Q = 1,test = 1;
| ^~~~| # | 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... |