이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "cyberland.h"
#pragma GCC optimize("Ofast")
#pragma GCC optimize("03")
#pragma GCC tartget("avx2")
using namespace std;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>
const int MAX=1e5+15;
const double inf=1e18;
double solve(int n,int m,int k,int h,vector<int> x,vector<int> y,vector<int> c,vector<int> arr){
vector<pii> g[n+1];
double dp[n+1][32];
for(int i=0;i<m;i++){
x[i]++;
y[i]++;
g[x[i]].pb({y[i],c[i]});
g[y[i]].pb({x[i],c[i]});
// cout<<x[i]<<" "<<y[i]<<" "<<c[i]<<"\n";
}
k=min(k,30);
h++;
for(int i=1;i<=n;i++){
for(int j=0;j<=k;j++)dp[i][j]=inf;
}
dp[1][0]=0;
priority_queue<pair<double,pii>> q;
q.push({0,{1,0}});
while(!q.empty()){
pair<double,pii> boofer=q.top();
q.pop();
int v=boofer.S.F,c=boofer.S.S;
if(dp[v][c]<boofer.F||v==h)continue;
// cout<<v<<" "<<c<<" "<<dp[v][c]<<"\n";
for(auto to:g[v]){
if(arr[to.F-1]==0){
if(dp[to.F][c]>0){
dp[to.F][c]=0;
q.push({dp[to.F][c],{to.F,c}});
}
}
else if(arr[to.F-1]==1){
if(dp[v][c]+to.S<dp[to.F][c]){
dp[to.F][c]=dp[v][c]+to.S;
q.push({dp[to.F][c],{to.F,c}});
}
}
else{
if(dp[v][c]+to.S<dp[to.F][c]){
dp[to.F][c]=dp[v][c]+to.S;
q.push({dp[to.F][c],{to.F,c}});
}
if(c+1<=k&&(dp[v][c]+to.S)/2<dp[to.F][c+1]){
dp[to.F][c+1]=(dp[v][c]+to.S)/2;
q.push({dp[to.F][c+1],{to.F,c+1}});
}
}
}
}
double ans=inf;
for(int i=0;i<=k;i++)ans=min(ans,dp[h][i]);
if(ans==inf)return -1.0;
return ans;
}
// int main(){
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
// int t;
// cin>>t;
// cout.precision(10);
// while(t--){
// int n,m,k,h;
// cin>>n>>m>>k>>h;
// vector<int> arr(n);
// for(int i=0;i<n;i++)cin>>arr[i];
// vector<int> x(m),y(m),c(m);
// for(int i=0;i<m;i++)cin>>x[i]>>y[i]>>c[i];
// cout<<fixed<<solve(n,m,k,h,x,y,c,arr)<<"\n";
// }
// }
컴파일 시 표준 에러 (stderr) 메시지
cyberland.cpp:6: warning: ignoring '#pragma GCC tartget' [-Wunknown-pragmas]
6 | #pragma GCC tartget("avx2")
|
# | 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... |