# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
494333 | ktkerem | Alias (COCI21_alias) | C++17 | 149 ms | 576 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll _i=0;
#define ffn(x) _i=x
#define llll pair<ll , ll>
#define stitr set<llll>::iterator
#define fora(y,x) for(ll y=_i;x>y;y++)
#define pb push_back
#define pf push_front
#define debu cout << "hello\n"
#define fi first
#define sec second
#define all(a) a.begin() , a.end()
const ll limit = 1e13 + 7;
const ll ous=1e6 + 5;
const ll dx[4] = {1 , -1 , 0 , 0} , dy[4] = {0,0,-1,1};
void solve(){
ll n , m;cin >> n >> m;
map<string , vector<pair<ll , string>>> adj;
fora(i,m){
string h , y;ll x;cin >> h >> y >> x;
adj[h].pb({x , y});
}
ll q;cin >> q;
while(q--){
map<string , ll> vis;
string src , trg;
cin >> src >> trg;
priority_queue<pair<ll , string> , vector<pair<ll , string>> , greater<pair<ll , string>>> pq;
pq.push({0 , src});
ll kd = 0;
while(!pq.empty()){
ll a = pq.top().fi;
string sa = pq.top().sec;
pq.pop();
if(vis[sa] == 1){
continue;
}
vis[sa] = 1;
//cout << sa << "\n";
if(sa == trg){
cout << a << "\n";
kd = 1;
break;
}
for(auto j:adj[sa]){
if(vis[j.sec] == 0){
pq.push({j.fi + a , j.sec});
}
}
}
if(kd == 0){
cout << "Roger\n";
}
}
return;
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
ll t=1;
//cin >> t;
while(t--){
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |