Submission #734629

#TimeUsernameProblemLanguageResultExecution timeMemory
734629rahidilbayramliAlias (COCI21_alias)C++17
70 / 70
31 ms468 KiB
#include<bits/stdc++.h> #define ll long long #define vl vector<ll> #define sl set<ll> #define all(v) v.begin(), v.end() #define f first #define s second #define pb push_back #define pll pair<ll, ll> #define pii pair<int, int> #define tests while(t--) using namespace std; const ll sz = 1010, inf = 1e15; ll dist[sz]; vector<pair<ll, int>>adj[sz]; int n, m, i, j; void dijkstra(int src) { for(i = 1; i <= n; i++) dist[i] = inf; dist[src] = 0; using T = pair<ll, int>; priority_queue<T, vector<T>, greater<T>>q; q.push({0ll, src}); while(!q.empty()) { int node; ll cdist; tie(cdist, node) = q.top(); q.pop(); if(cdist != dist[node]) continue; for(auto u : adj[node]) { if(cdist + u.s < dist[u.f]) { dist[u.f] = cdist + u.s; q.push({dist[u.f], u.f}); } } } } int main() { ll c, l, x, y, q; string a, b; cin >> n >> m; set<string>st; map<string, ll>mp; for(i = 0; i < m; i++) { cin >> a >> b >> c; l = st.size(); st.insert(a); if(st.size() != l) mp[a] = st.size(); l = st.size(); st.insert(b); if(st.size() != l) mp[b] = st.size(); x = mp[a], y = mp[b]; adj[x].pb({y, c}); } cin >> q; while(q--) { cin >> a >> b; x = mp[a], y = mp[b]; dijkstra(x); if(dist[y] == inf) cout << "Roger\n"; else cout << dist[y] << "\n"; } }

Compilation message (stderr)

alias.cpp: In function 'int main()':
alias.cpp:53:22: warning: comparison of integer expressions of different signedness: 'std::set<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   53 |         if(st.size() != l)
      |            ~~~~~~~~~~^~~~
alias.cpp:57:22: warning: comparison of integer expressions of different signedness: 'std::set<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   57 |         if(st.size() != l)
      |            ~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...