# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
836732 | SoulKnight | 사이버랜드 (APIO23_cyberland) | C++17 | 721 ms | 92000 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cyberland.h"
// #include "bits/stdc++.h"
#include <vector>
#include <iostream>
#include <array>
#include <queue>
#include <numeric>
#include <cassert>
#include <set>
using namespace std;
#define ll long long
#define ln '\n'
const int N = 1e5 + 5;
const int LG = 52;
const long double INF = 1e16;
vector<array<ll, 2>> adj[N];
long double dist[N][LG], p2[LG];
priority_queue<array<long double, 3>, vector<array<long double, 3>>, greater<array<long double, 3>>> pq;
set<int> node;
queue<int> q;
bool seen[N];
double solve(int NN, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
for (int i = 0; i < NN; i++) {adj[i].clear(); seen[i] = 0;}
node.clear();
K = min(K, 50);
p2[0] = 1.0;
for (int i = 1; i < LG; i++) p2[i] = p2[i-1] * 2.0;
for (int i = 0; i < M; i++){
adj[x[i]].push_back({c[i], y[i]});
adj[y[i]].push_back({c[i], x[i]});
}
q.push(0); seen[0] = 1;
while (!q.empty()){
int cur = q.front(); q.pop();
if (cur == H) continue;
for (auto& [e, v]: adj[cur]){
if (seen[v]) continue;
seen[v] = 1;
if (arr[v] == 0) node.insert(v);
q.push(v);
}
}
for (int i = 0; i < NN; i++){
for (int j = 0; j < LG; j++) dist[i][j] = INF;
}
for (int j = 0; j < LG; j++) dist[H][j] = 0.0;
pq.push({0.0, H, 0}); // (w, node, # of /2)
long double ans = INF;
while (!pq.empty()){
long double w = pq.top()[0];
int u = pq.top()[1];
int cnt = pq.top()[2];
pq.pop();
// cout << w << ' ' << u << ' ' << cnt << ln;
// cout << (w > dist[u][cnt]) << ln;
if (w > dist[u][cnt]) continue;
if (arr[u] == 0 && node.count(u)) {ans = min(ans, w); continue;}
// cout << "what" << ln;
for (auto& [e, v]: adj[u]){
// cout << v << ' ' << dist[v][cnt] << ln;
if (dist[v][cnt] >= INF || w + e / p2[cnt] < dist[v][cnt]){
dist[v][cnt] = w + e / p2[cnt];
pq.push({dist[v][cnt], v, min(K, cnt + (arr[v] == 2))});
}
}
}
for (int j = 0; j <= K; j++){
ans = min(ans, dist[0][j]);
// cout << dist[0][j] << " ";
}
ans = ((ans >= INF)? -1: ans);
return ans;
}
컴파일 시 표준 에러 (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... |