# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28627 | 쥬니님일어나세요 버스운전해주시기로했잖아요 (#68) | Alternative Mart (FXCUP2_mart) | C++14 | 3 ms | 8544 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <deque>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll,ll> Pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()
#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)
#define INF 987654321
#define IINF 87654321987654321
#define MAXV 200500
#define MOD 1234567
int N,M,K,T;
vector<int> pos;
vector<Pll> E[60000];
ll dist[60000]; int pa[60000];
bool vis[60000];
set<int> used[60000];
vector<Pll> s[60000];
typedef pair<ll,Pll> ppll;
int main(){
rep(i,60000) dist[i] = IINF;
geti(N,M,K,T);
repp(i,K){
int x; geti(x); pos.pb(x);
}
repp(i,M){
ll a,b,c; scanf("%lld%lld%lld",&a,&b,&c);
E[a].push_back({b,c}); E[b].push_back({a,c});
}
priority_queue<ppll, vector<ppll>, greater<ppll>> pq;
for(auto e : pos){
pq.push({0,{e,e}}); dist[e] = 0; vis[e] =true;
pa[e] = e; used[e].insert(e);
s[e].push_back({0,e});
}
while(!pq.empty()){
ll curd = pq.top().Fi; int cur = pq.top().Se.Fi;
int p = pq.top().Se.Se;
/*
if( used[cur].find(p) == used[cur].end() ){
used[cur].insert(p);
s[cur].insert({curd,p});
}
*/
pq.pop();
for(auto e : E[cur]){
if( used[e.Fi].size() >= 11 ) continue;
if( used[e.Fi].find( p ) != used[e.Fi].end() ){
for(auto& x : s[e.Fi]){
if(x.Se == p ){
x.Fi = min( x.Fi, curd+e.Se);
}
}
continue;
}
used[e.Fi].insert(p);
s[e.Fi].push_back({curd+e.Se,p});
pq.push({curd+e.Se,{e.Fi,p}});
}
}
/*
repp(i,N){
for(auto e : s[i]){
cout << i << " " << e.Fi << " " << e.Se << endl;
}
}
*/
//cout << T << endl;
repp(i,N) sort(all(s[i]));
repp(i,T){
int S; geti(S);
int X; geti(X);
set<int> die;
repp(i,X){
int y; geti(y); die.insert(y);
}
//for(auto e : die) printf("[%d]",e);
bool ok = false;
for(auto e : s[S]){
if( die.find(e.Se) == die.end() ){
printf("%lld %lld\n",e.Se,e.Fi);
//printf("!");
ok = true;
break;
}
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |