QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#591992 | #6527. Cyberland | isirazeev | 0 | 60ms | 3768kb | C++20 | 1.8kb | 2024-09-26 19:50:14 | 2024-09-26 19:50:14 |
Judging History
answer
#include "cyberland.h"
#include <vector>
#include <set>
#include <iostream>
using namespace std;
const long long INF = (long long) 1e18;
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) {
long double dp[N][K + 1];
for(int i = 0; i < N; i++){
for(int j = 0; j <= K; j++)
dp[i][j] = INF;
}
set<pair<long double, pair<int, int>>> st;
vector<pair<int, int>> g[N];
for(int i = 0; i < M; i++){
g[x[i]].emplace_back(y[i], c[i]);
g[y[i]].emplace_back(x[i], c[i]);
}
for(int i = 0; i < N; i++){
if(arr[i] == 0){
dp[i][0] = 0;
st.insert({0, {i, 0}});
}
}
dp[0][0] = 0;
st.insert({0, {0, 0}});
while(!st.empty()){
auto pr = *st.rbegin();
st.erase(pr);
int v = pr.second.first, j = pr.second.second;
if(v == H) continue;
for(auto p : g[v]){
int u = p.first, c = p.second;
if(dp[u][j] > dp[v][j] + c){
st.erase({dp[u][j], {u, j}});
dp[u][j] = dp[v][j] + c;
st.insert({dp[u][j], {u, j}});
}
if(arr[u] == 2 && j + 1 <= K && dp[u][j + 1] > (dp[v][j] + c) / 2){
st.erase({dp[u][j + 1], {u, j + 1}});
dp[u][j + 1] = (dp[v][j] + c) / 2;
st.insert({dp[u][j + 1], {u, j + 1}});
}
if(arr[v] == 1 && j + 1 <= K && dp[u][j + 1] > dp[v][j] / 2 + c){
st.erase({dp[u][j + 1], {u, j + 1}});
dp[u][j + 1] = dp[v][j] / 2 + c;
st.insert({dp[u][j + 1], {u, j + 1}});
}
}
}
long double res = INF;
for(int j = 0; j <= K; j++)
res = min(res, dp[H][j]);
return res;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 60ms
memory: 3768kb
input:
10000 2 1 30 1 1 1 1 0 13080 3 3 30 1 1 1 1 0 2 25242 2 1 13399 1 0 2123 2 1 30 1 1 1 0 1 11947 2 1 30 1 1 1 0 1 27361 3 0 30 2 1 0 1 2 0 30 1 1 1 3 2 30 1 1 1 2 1 2 23211 0 1 9991 3 1 30 1 1 1 1 2 1 3093 2 1 30 1 1 1 1 0 10703 2 1 30 1 1 1 0 1 15754 2 1 30 1 1 1 1 0 18752 2 1 30 1 1 1 1 0 2300 2 1 ...
output:
a9100fda0a7059a979d560b8550f715d4ee391ff9b8b680b2f87b26a69ee5a5e 13080.000000000000000 2123.000000000000000 11947.000000000000000 27361.000000000000000 1000000000000000000.000000000000000 1000000000000000000.000000000000000 9991.000000000000000 1000000000000000000.000000000000000 10703.0000000000000...
result:
wrong answer Wrong Answer.
Subtask #2:
score: 0
Time Limit Exceeded
Test #3:
score: 0
Time Limit Exceeded
input:
100 982 981 30 107 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
a9100fda0a7059a979d560b8550f715d4ee391ff9b8b680b2f87b26a69ee5a5e
result:
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Time Limit Exceeded
Test #19:
score: 0
Time Limit Exceeded
input:
1 58243 58242 30 14059 1 2 0 1 0 2 2 0 0 0 1 0 2 0 2 1 2 1 0 0 0 2 1 0 0 0 0 1 2 1 0 2 0 2 2 2 2 2 0 0 2 2 1 2 1 2 0 2 2 1 2 0 0 1 0 0 0 0 2 2 0 0 2 2 1 0 0 0 2 2 0 1 2 1 0 2 0 0 2 0 1 0 2 1 2 2 1 1 2 1 2 1 2 2 0 1 0 1 1 2 1 2 2 1 0 1 2 1 2 1 0 2 2 2 1 2 0 1 0 1 0 1 2 0 0 0 2 2 1 1 1 2 0 1 2 2 2 2 1...
output:
a9100fda0a7059a979d560b8550f715d4ee391ff9b8b680b2f87b26a69ee5a5e
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #24:
score: 0
Time Limit Exceeded
input:
100 442 637 30 269 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
a9100fda0a7059a979d560b8550f715d4ee391ff9b8b680b2f87b26a69ee5a5e
result:
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #6:
0%
Subtask #8:
score: 0
Skipped
Dependency #1:
0%