Submission #103526

#TimeUsernameProblemLanguageResultExecution timeMemory
103526AllianceCommuter Pass (JOI18_commuter_pass)C++14
0 / 100
1362 ms28012 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,int>> 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]) { int u = x.first; int w = x.second; int 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 dfs(int v) { mark[v]++; vers.push_back(v); for(auto x:p[v]) { if (!mark[x]) dfs(x); } } int main() { cin >> n >> m >> s >> t >> u >> v; if (s!=u) exit(1); 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(); dfs(t); dij(); cout << dis[v]; return 0; }

Compilation message (stderr)

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:68: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...