# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
822656 | Hanksburger | Cyberland (APIO23_cyberland) | C++17 | 318 ms | 28760 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 "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<double, int> > pq;
vector<pair<int, int> > adj[100005];
int ok[100005], final[100005];
double dist[65][100005];
queue<int> q;
double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> a)
{
k=min(k, 60);
for (int i=0; i<n; i++)
{
adj[i].clear();
ok[i]=0;
}
for (int i=0; i<m; i++)
{
adj[x[i]].push_back({y[i], c[i]});
adj[y[i]].push_back({x[i], c[i]});
}
ok[0]=1;
q.push(0);
while (!q.empty())
{
int u=q.front();
q.pop();
if (u==h)
continue;
for (int i=0; i<adj[u].size(); i++)
{
int v=adj[u][i].first;
if (!ok[v])
{
ok[v]=1;
q.push(v);
}
}
}
for (int i=0; i<=k; i++)
for (int j=0; j<n; j++)
dist[i][j]=1e18;
dist[0][0]=0;
pq.push({0, 0});
for (int i=0; i<=k; i++)
{
for (int j=0; j<n; j++)
{
if (ok[j] && !a[j])
{
dist[i][j]=0;
pq.push({0, j});
}
}
if (i)
{
for (int j=0; j<n; j++)
{
if (ok[j] && a[j]==2)
{
for (int l=0; l<adj[j].size(); l++)
{
int v=adj[j][l].first, w=adj[j][l].second;
dist[i][v]=min(dist[i][v], dist[i-1][j]/2+w);
pq.push({-dist[i][v], v});
}
}
}
}
for (int j=0; j<n; j++)
final[j]=0;
while (!pq.empty())
{
int u=pq.top().second;
pq.pop();
if (final[u])
continue;
final[u]=1;
for (int j=0; j<adj[u].size(); j++)
{
int v=adj[u][j].first, w=adj[u][j].second;
if (dist[i][u]+w<dist[i][v])
{
dist[i][v]=dist[i][u]+w;
pq.push({-dist[i][v], v});
}
}
}
}
double mn=1e18;
for (int i=0; i<=k; i++)
mn=min(mn, dist[i][h]);
if (mn<5e17)
return mn;
else
return -1;
}
Compilation message (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... |