# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
943743 | vjudge1 | Alias (COCI21_alias) | C++11 | 365 ms | 856 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |