답안 #943743

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
943743 2024-03-11T19:32:53 Z vjudge1 Alias (COCI21_alias) C++11
40 / 70
365 ms 856 KB
#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

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++){
      |                         ~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Incorrect 301 ms 716 KB Output isn't correct
4 Incorrect 365 ms 604 KB Output isn't correct
5 Correct 6 ms 856 KB Output is correct
6 Correct 5 ms 604 KB Output is correct
7 Correct 3 ms 604 KB Output is correct