Submission #736263

#TimeUsernameProblemLanguageResultExecution timeMemory
736263rahidilbayramliAlias (COCI21_alias)C++17
50 / 70
22 ms724 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define vl vector<ll> #define sl set<ll> #define conn continue #define tests while(t--) #define pii pair<int, int> #define pll pair<ll, ll> #define all(v) v.begin(), v.end() #define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define f first #define s second using namespace std; const int sz = 1e4+5, inf = 1e9+7; int dist[sz]; int n, m, i, j, l, c, q; vector<pair<ll, int>>g[sz]; string a, b; 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>>pq; pq.push({0ll, src}); while(!pq.empty()) { int node; ll cdist; tie(cdist, node) = pq.top(); pq.pop(); if(cdist != dist[node]) continue; for(auto u : g[node]) { if(cdist + u.s < dist[u.f]) { dist[u.f] = cdist + u.s; pq.push({dist[u.f], u.f}); } } } } int main() { int x, y; map<string, ll>mp; set<string>st; cin >> n >> m; for(i = 0; i < m; i++) { cin >> a >> b >> c; l = st.size(); st.insert(a); if(l != st.size()) mp[a] = st.size(); l = st.size(); st.insert(b); if(l != st.size()) mp[b] = st.size(); x = mp[a], y = mp[b]; g[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:56:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::set<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |         if(l != st.size())    mp[a] = st.size();
      |            ~~^~~~~~~~~~~~
alias.cpp:59:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::set<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         if(l != st.size())    mp[b] = st.size();
      |            ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...