| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 519881 | Vianti | Alias (COCI21_alias) | C++17 | 40 ms | 620 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const ll INF = 1e18;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    map<string, int> id;
    set<string> st;
    int cnt = 0;
    vector<vector<pair<int, ll>>> g(n);
    for (int i = 0; i < m; i++) {
        string s1, s2;
        cin >> s1 >> s2;
        if (st.find(s1) == st.end()) {
            st.insert(s1);
            id[s1] = cnt++;
        }
        if (st.find(s2) == st.end()) {
            st.insert(s2);
            id[s2] = cnt++;
        }
        ll x;
        cin >> x;
        g[id[s1]].push_back({id[s2], x});
    }
    int q;
    cin >> q;
    for (int t = 0; t < q; t++) {
        string s1, s2;
        cin >> s1 >> s2;
        int s = id[s1];
        int f = id[s2];
        vector<ll> d(n, INF);
        d[s] = 0;
        set<pair<ll, int>> queue;
        queue.insert({0, s});
        while (!queue.empty()) {
            int v = queue.begin()->second;
            queue.erase(queue.begin());
            for (auto& to: g[v]) {
                if (d[v] + to.second < d[to.first]) {
                    queue.erase({d[to.first], to.first});
                    d[to.first] = d[v] + to.second;
                    queue.insert({d[to.first], to.first});
                }
            }
        }
        if (d[f] == INF) {
            cout << "Roger" << endl;
        } else {
            cout << d[f] << endl;
        }
    }
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
