# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
486448 | davi_bart | Alias (COCI21_alias) | C++14 | 103 ms | 516 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define fi first
#define se second
#define ld long double
#define pb push_back
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
map<string, vector<pair<string, int>>> v;
string ans(string a, string b) {
priority_queue<pair<int, string>, vector<pair<int, string>>, greater<pair<int, string>>> q;
set<string> vis;
q.push({0, a});
while (!q.empty()) {
auto [d, pos] = q.top();
q.pop();
if (vis.count(pos)) continue;
vis.insert(pos);
if (pos == b) return to_string(d);
for (auto [x, y] : v[pos]) {
q.push({d + y, x});
}
}
return "Roger";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N, M;
cin >> N >> M;
for (int i = 0; i < M; i++) {
string a, b;
int c;
cin >> a >> b >> c;
v[a].pb({b, c});
}
int Q;
cin >> Q;
while (Q--) {
string a, b;
cin >> a >> b;
cout << ans(a, b) << '\n';
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |