| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 421053 | Chaska | Alias (COCI21_alias) | C++11 | 132 ms | 47700 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>
#define F first
#define S second
using namespace std;
typedef pair<int,int> i2;
typedef vector<i2> vii;
typedef pair<string,string> s2;
typedef pair<s2,int> s3;
const int N = 3e5+5;
int n,m;
vii g[N];
set<string> s;
map<string,int> h;
s3 a[N];
int q;
s2 b[N]; 
bool vs[N];
int val[N]; 
priority_queue<i2,vii,greater<i2>> pq;
int main()
{
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
    cin >> n >> m;
    for (int i=0;i<m;i++) {
        cin >> a[i].F.F >> a[i].F.S >> a[i].S;
        s.insert(a[i].F.F);
        s.insert(a[i].F.S);
    }
    cin >> q;
    for (int i=0;i<q;i++) {
        cin >> b[i].F >> b[i].S;
        s.insert(b[i].F);
        s.insert(b[i].S);
    }
    int cnt = 0;
    for (string u :s) h[u] = ++cnt;
    for (int i=0;i<m;i++) {
        g[h[a[i].F.F]].push_back({h[a[i].F.S],a[i].S});
    }
    for (int i=0;i<q;i++) {
        for (int j=1;j<=n;j++) vs[j] = val[j] = 0;
        pq.push({0,h[b[i].F]});
        while (!pq.empty()) {
            auto x = pq.top();
            pq.pop();
            if (!vs[x.S]) {
                vs[x.S] = true;
                val[x.S] = x.F;
                for (auto v : g[x.S]) {
                    pq.push({x.F+v.S,v.F});
                }
            }
        }
        if (val[h[b[i].S]] == 0) cout << "Roger\n";
        else cout << val[h[b[i].S]] << "\n";
    }
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
