# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28597 | 맞왜틀 맞왜틀 신나는노래~ 헤이! 나도한번 불러보자 (#68) | Alternative Mart (FXCUP2_mart) | C++11 | 1929 ms | 79976 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 <cstdio>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
std::vector<std::pair<int,int>> G[50010];
std::vector<std::pair<int,int>> CK[50010];
struct node{
int v, id, from;
};
bool operator<(node n1, node n2){
return std::make_pair(-n1.v,n1.from) < std::make_pair(-n2.v,n2.from);
}
int main(){
int N,M,K,Q;
scanf("%d%d%d%d",&N,&M,&K,&Q);
std::priority_queue<node> q;
for(int i =0 ; i< K;i++){
int v;
scanf("%d",&v);
q.push({0,v,v});
}
for(int i = 0; i < M ; i++){
int A,B,C;
scanf("%d%d%d",&A,&B,&C);
G[A].push_back({B,C});
G[B].push_back({A,C});
}
while(q.size() != 0){
auto t = q.top();
q.pop();
if(CK[t.id].size() > 15) continue;
bool flag = false;
for(auto i : CK[t.id]){
if(i.second == t.from) {
flag = true;
break;
}
}
if(flag) continue;
CK[t.id].push_back({t.v,t.from});
for(auto i : G[t.id]){
q.push({t.v+i.second,i.first,t.from});
}
}
for(int i =0 ; i < Q;i ++){
int S, X;
scanf("%d%d",&S,&X);
std::set<int> PC;
for(int j =0; j < X; j++){
int v;
scanf("%d",&v);
PC.insert(v);
}
std::sort(CK[S].begin(),CK[S].end());
for(auto j : CK[S]){
if(!PC.count(j.second)){
printf("%d %d\n",j.second,j.first);
break;
}
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |