제출 #890569

#제출 시각아이디문제언어결과실행 시간메모리
890569ByeWorldCommuter Pass (JOI18_commuter_pass)C++14
15 / 100
402 ms40424 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define bupol __builtin_popcount #define int long long #define ll long long #define ld long double #define fi first #define se second #define pb push_back #define lf (id<<1) #define rg ((id<<1)|1) #define md ((l+r)>>1) using namespace std; const int MAXN = 2e5+5; const int LOG = 20; const int MOD = 1e9+7; const int SQRT = 520; const int INF = 1e18; typedef pair<int,int> pii; typedef pair<int,pii> ipii; int n, m; int s, t, x, y; int u[MAXN], v[MAXN], c[MAXN]; vector <pii> adj[MAXN]; int dis[MAXN]; priority_queue<pii, vector<pii>, greater<pii>> pq; map<pii,int> ma; void dji(int sta){ for(int i=1; i<=n; i++) dis[i] = INF; pq.push({0, sta}); dis[sta] = 0; while(!pq.empty()){ int tp = pq.top().se; int dist = pq.top().fi; pq.pop(); if(dis[tp] < dist) continue; for(auto ed : adj[tp]){ int nx = ed.fi; int wei = ed.se; if(dis[nx] > dist+wei){ dis[nx] = dist+wei; pq.push({dis[nx], nx}); } } } } signed main(){ //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m; cin >> s >> t; cin >> x >> y; for(int i=1; i<=m; i++){ cin >> u[i] >> v[i] >> c[i]; if(u[i] > v[i]) swap(u[i], v[i]); ma[pii(u[i], v[i])] = i; adj[u[i]].pb({v[i], c[i]}); adj[v[i]].pb({u[i], c[i]}); } dji(s); //cout << dis[t] << " dis\n"; vector <int> path; path.pb(t); int nw = t, dist = dis[t]; while(nw != s){ for(auto ed : adj[nw]){ if(dis[ed.fi] == dist-ed.se){ path.pb(ed.fi); nw = ed.fi; dist -= ed.se; break; } } } for(int i=0; i+1<path.size(); i++){ int nw = path[i], nx = path[i+1]; if(nw > nx) swap(nw, nx); int idx = ma[pii(nw, nx)]; c[idx] = 0; } for(int i=1; i<=n; i++) adj[i].clear(); for(int i=1; i<=m; i++){ adj[u[i]].pb({v[i], c[i]}); adj[v[i]].pb({u[i], c[i]}); } dji(x); cout << dis[y] << '\n'; }

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

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:70:21: 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]
   70 |     for(int i=0; i+1<path.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...