Submission #103530

#TimeUsernameProblemLanguageResultExecution timeMemory
103530AllianceCommuter Pass (JOI18_commuter_pass)C++14
15 / 100
1227 ms25460 KiB
// In the name of Allah. Ya ali! #include<bits/stdc++.h> #define double long double typedef long long ll; const ll MAX_N = 1e5+10; const ll MOD = 1e9+7; using namespace std; vector<pair<int,ll>> g[MAX_N]; ll dis[MAX_N]; int mark[MAX_N]; vector<int> p[MAX_N]; int s,t,u,v; vector<int> vers; int n,m; void dij() { for(int i = 1;i<=n;++i) dis[i] = 1e18; for(auto x:vers) dis[x] = 0; set<pair<ll,int>> st; for(int i = 1;i<=n;++i) st.insert({dis[i],i}); while(st.size()) { int v = (*st.begin()).second; st.erase(st.begin()); for(auto x:g[v]) { ll u = x.first; int w = x.second; ll d = dis[v]+w; if (dis[u]==d) p[u].push_back(v); else if (dis[u]>d) { st.erase({dis[u],u}); dis[u] = d; st.insert({dis[u],u}); p[u].clear(); p[u].push_back(v); } } } } void make_zero(int u,int v) { for(int i = 0;i<g[u].size();++i) { if (g[u][i].first==v) g[u][i].second = 0; } for(int i = 0;i<g[v].size();++i) { if (g[v][i].first==u) g[v][i].second = 0; } } int main() { cin >> n >> m >> s >> t >> u >> v; for(int i = 0;i<m;++i) { int a,b,w; scanf("%d%d%d",&a,&b,&w); g[a].push_back({b,w}); g[b].push_back({a,w}); } vers.push_back(s); dij(); vers.clear(); vector<int> path; int now = t; while(p[now].size()) { path.push_back(now); now = p[now][0]; } path.push_back(now); for(int i = 0;i<path.size()-1;++i) make_zero(path[i],path[i+1]); vers.push_back(u); dij(); cout << dis[v]; return 0; }

Compilation message (stderr)

commuter_pass.cpp: In function 'void make_zero(int, int)':
commuter_pass.cpp:51:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<g[u].size();++i)
                   ~^~~~~~~~~~~~
commuter_pass.cpp:56:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<g[v].size();++i)
                   ~^~~~~~~~~~~~
commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:84:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<path.size()-1;++i)
                   ~^~~~~~~~~~~~~~
commuter_pass.cpp:69:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&a,&b,&w);
         ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...