Submission #943743

#TimeUsernameProblemLanguageResultExecution timeMemory
943743vjudge1Alias (COCI21_alias)C++11
40 / 70
365 ms856 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n,m; cin>>n>>m; string x,y; long long t; map<string,vector<pair<string,long long> > >db; for(int i=0;i<m;i++){ cin>>x>>y>>t; db[x].push_back(make_pair(y,t)); } int q; cin>>q; for(int i=0;i<q;i++){ cin>>x>>y; map<string,long long>dist; queue<string>q; dist[x]=0; q.push(x); while(!q.empty()){ string next=q.front(); q.pop(); vector<pair<string,long long> >conexiones=db[next]; for(int i=0;i<conexiones.size();i++){ string recuerdo=conexiones[i].first; long long tiempo=conexiones[i].second; if(dist.count(recuerdo)==0){ dist[recuerdo]=dist[next]+tiempo; q.push(recuerdo); } else dist[recuerdo]=min(dist[recuerdo],dist[next]+tiempo); } } if(dist.count(y))cout<<dist[y]<<"\n"; else cout<<"Roger\n"; } return 0; }

Compilation message (stderr)

alias.cpp: In function 'int main()':
alias.cpp:28:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::__cxx11::basic_string<char>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             for(int i=0;i<conexiones.size();i++){
      |                         ~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...