# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
777493 | groshi | 사이버랜드 (APIO23_cyberland) | C++17 | 3079 ms | 94156 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#pragma GCC optimize "unroll-loops"
#pragma GCC optimize "O3"
#include "cyberland.h"
using namespace std;
struct wi{
vector<int> Q;
double dp[71];
int co;
int odw=0;
}*w;
vector<int> moge;
void dfs(int x,int nie)
{
w[x].odw=1;
if(x==nie)
return;
if(w[x].co==0)
moge.push_back(x);
for(int i=0;i<w[x].Q.size();i+=2)
if(w[w[x].Q[i]].odw==0)
dfs(w[x].Q[i],nie);
}
double solve(int32_t n,int32_t m,int32_t k,int32_t h,vector<int32_t> x,vector<int32_t> y,vector<int32_t> c, vector<int32_t> arr)
{
w=new wi[n+3];
for(int i=0;i<m;i++)
{
if(x[i]!=h)
w[x[i]].Q.push_back(y[i]),w[x[i]].Q.push_back(c[i]);
if(y[i]!=h)
w[y[i]].Q.push_back(x[i]),w[y[i]].Q.push_back(c[i]);
}
for(int i=0;i<n;i++)
w[i].co=arr[i];
moge.clear();
dfs(0,h);
moge.push_back(0);
priority_queue<pair<double,pair<int,int> > > kolejka;
k=min(k,70);
for(int i=0;i<n;i++)
for(int j=0;j<=k;j++)
w[i].dp[j]=1e14;
for(int i=0;i<moge.size();i++)
{
kolejka.push({0.0,{moge[i],0}});
for(int j=0;j<=k;j++)
w[moge[i]].dp[j]=0;
}
while(!kolejka.empty())
{
auto para=kolejka.top();
kolejka.pop();
int x=para.second.first;
int typ=para.second.second;
double ile=-para.first;
if(ile>w[x].dp[typ])
continue;
for(int i=0;i<w[x].Q.size();i+=2)
{
int pom=w[x].Q[i];
double dodaj=w[x].Q[i+1];
if(w[pom].dp[typ]>ile+dodaj)
kolejka.push({-ile-dodaj,{pom,typ}}),w[pom].dp[typ]=ile+dodaj;
if(w[pom].co!=2)
continue;
dodaj+=ile;
dodaj/=2;
if(w[pom].dp[typ+1]>dodaj && typ+1<=k)
kolejka.push({-dodaj,{pom,typ+1}}),w[pom].dp[typ+1]=dodaj;
}
}
double minn=1e14;
for(int i=0;i<=k;i++)
minn=min(minn,w[h].dp[i]);
if(minn==1e14)
return -1;
else return minn;
}
컴파일 시 표준 에러 (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... |