# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
849130 | Hyojin | 악어의 지하 도시 (IOI11_crocodile) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define bit(n,i) ((n>>i)&1)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define ep emplace_back
#define pii pair<int,int>
#define piii pair<int,pii>
#define fi first
#define se second
#define ll long long
#define debug(x) cerr << #x << ' ' << x << '\n'
#define dbg(x) cerr<<#x<<' '<<x<<' '
const int base=31;
const int MOD=1e9+7;
const int N=1e5+5;
void setIO(const string &NAME)
{
if (NAME.size())
{
freopen((NAME+".inp").c_str(),"r",stdin);
freopen((NAME+".out").c_str(),"w",stdout);
}
}
pair<ll,ll>d[N];
bool vis[N];
vector<pii>adj[N];
ll travel_plan(int n,int m,int r[][2],int l[],int k,int p[])
{
for (int i=0;i<m;i++)
{
int u=r[i][0],v=r[i][1];
adj[u].pb({v,l[i]});
adj[v].pb({u,l[i]});
}
for (int i=0;i<n;i++) d[i]={1e18,1e18};
priority_queue<pair<ll,int>>pq;
for (int i=0;i<k;i++)
{
pq.push({0,p[i]});
d[p[i]]={0,0};
}
while (pq.size())
{
auto [cost,u]=pq.top();
cost=-cost;
pq.pop();
if (vis[u]) continue;
vis[u]=1;
for (auto [v,w]:adj[u])
{
if (cost+w<d[v].se)
{
d[v].se=cost+w;
if (d[v].se<d[v].fi) swap(d[v].fi,d[v].se);
if (d[v].se!=1e18) pq.push({-d[v].se,v});
}
}
}
return d[0].se;
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifdef Amon
setIO("Amon");
#endif
return 0;
}