# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
814526 | Hanksburger | 사이버랜드 (APIO23_cyberland) | C++17 | 1704 ms | 345496 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long double> > adj[3000005];
priority_queue<pair<long double, long long> > pq;
long long final[3000005], ok[100005], h;
long double dist[3000005];
void dfs(long long u)
{
ok[u]=1;
for (long long i=0; i<adj[u].size(); i++)
{
long long v=adj[u][i].first;
if (ok[v] || v==h)
continue;
dfs(v);
}
}
double solve(int n, int m, int k, int hh, vector<int> x, vector<int> y, vector<int> c, vector<int> a)
{
h=hh;
k=min(k, 30);
for (long long i=0; i<(k+1)*n; i++)
adj[i].clear();
for (long long i=0; i<m; i++)
{
for (long long j=0; j<=k; j++)
{
adj[j*n+x[i]].push_back({j*n+y[i], (long double)c[i]/(1LL<<(k-j))});
adj[j*n+y[i]].push_back({j*n+x[i], (long double)c[i]/(1LL<<(k-j))});
if (j<k)
{
if (a[x[i]]==2)
adj[j*n+y[i]].push_back({(j+1)*n+x[i], (long double)c[i]/(1LL<<(k-j))});
if (a[y[i]]==2)
adj[j*n+x[i]].push_back({(j+1)*n+y[i], (long double)c[i]/(1LL<<(k-j))});
}
}
}
for (long long i=0; i<n; i++)
ok[i]=0;
dfs(0);
for (long long i=0; i<(k+1)*n; i++)
{
dist[i]=1e18;
final[i]=0;
}
dist[0]=0;
pq.push({0, 0});
for (long long i=1; i<n; i++)
{
if (!a[i] && ok[i])
{
dist[i]=0;
pq.push({0, i});
}
}
while (!pq.empty())
{
long long u=pq.top().second;
pq.pop();
if (final[u])
continue;
final[u]=1;
for (long long i=0; i<adj[u].size(); i++)
{
long long v=adj[u][i].first;
long double w=adj[u][i].second;
if (dist[u]+w<dist[v])
{
dist[v]=dist[u]+w;
pq.push({-dist[v], v});
}
}
}
long double ans=1e18;
for (long long i=0; i<=k; i++)
ans=min(ans, dist[i*n+h]*(1<<(k-i)));
if (ans<5e17)
return ans;
else
return -1;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |