이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O3,unroll-loops")
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int>> edges[100000];
double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
K = min(K,68);
for (int i=0;i<N;i++) edges[i].clear();
for (int i=0;i<M;i++) {
edges[x[i]].push_back({y[i],c[i]});
edges[y[i]].push_back({x[i],c[i]});
}
int ARR[arr.size()];
for (int i=0;i<arr.size();i++) ARR[i] = arr[i];
double dp[N][K+1];
for (int i=0;i<N;i++) {
for (int j=0;j<=K;j++) dp[i][j] = 2e18;
}
priority_queue<pair<double,pair<int,int>>,vector<pair<double,pair<int,int>>>,greater<pair<double,pair<int,int>>>> pq;
dp[0][0] = 0;
pq.push({0,{0,0}});
while (!pq.empty()) {
pair<double,pair<int,int>> f = pq.top();
pq.pop();
double cost = f.first;
int used = f.second.second;
int city = f.second.first;
if (dp[city][used] < cost) continue;
if (used && dp[city][used-1] < cost) {
dp[city][used] = dp[city][used-1];
continue;
}
if (city == H) continue;
for (auto it : edges[city]) {
int dest = it.first;
int go = it.second;
if (!ARR[dest]) {
if (dp[dest][used]>0) {
pq.push({0,{dest,used}});
dp[dest][used] = 0;
}
}
else {
if (dp[dest][used] > cost+go) {
pq.push({cost+go,{dest,used}});
dp[dest][used] = cost+go;
}
if (ARR[dest] == 2) {
if (dp[dest][used+1] > (cost+go)/2 && used!=K) {
pq.push({(cost+go)/2,{dest,used+1}});
dp[dest][used+1] = (cost+go)/2;
}
}
}
}
}
double ans = 2e18;
for (int i=0;i<=K;i++) ans = min(ans,dp[H][i]);
return ans==2e18?-1:ans;
}
컴파일 시 표준 에러 (stderr) 메시지
cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | for (int i=0;i<arr.size();i++) ARR[i] = arr[i];
| ~^~~~~~~~~~~
# | 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... |