QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#290238 | #6527. Cyberland | Max_s_xaM | 0 | 15ms | 26800kb | C++14 | 2.7kb | 2023-12-24 16:30:01 | 2023-12-24 16:30:01 |
Judging History
answer
#include "cyberland.h"
#include <iostream>
#include <algorithm>
#include <queue>
typedef long long ll;
typedef double lf;
using namespace std;
const int MAXN = 1e5 + 10, MAXM = 7e6 + 10;
int n, m, d, ed;
bool tp[MAXN];
int id[MAXN], idx[MAXN], cnt;
lf ans;
struct Edge
{
int v, nxt, w;
}e[MAXN << 1];
int head[MAXN], tot;
inline void AddEdge(int u, int v, int w)
{
if (u != ed) e[++tot] = Edge{v, head[u], w}, head[u] = tot;
if (v != ed) e[++tot] = Edge{u, head[v], w}, head[v] = tot;
}
bool vis[MAXN];
void DFS(int u)
{
vis[u] = 1;
for (int i = head[u]; ~i; i = e[i].nxt)
{
int v = e[i].v;
if (v == ed) vis[ed] = 1;
else if (!vis[v]) DFS(v);
}
}
lf dis[MAXM]; bool avl[MAXM];
priority_queue < pair <lf, int>, vector < pair <lf, int> >, greater < pair <lf, int> > > q;
lf solve(int N, int M, int K, int H, vector <int> FR, vector <int> TO, vector <int> CST, vector <int> ARR)
{
n = N, m = M, d = min(K, 30), ed = H + 1;
for (int i = 1; i <= n; i++)
{
tp[i] = ARR[i - 1];
head[i] = -1, vis[i] = id[i] = idx[i] = 0;
}
tot = -1;
for (int i = 1; i <= m; i++)
AddEdge(FR[i - 1] + 1, TO[i - 1] + 1, CST[i - 1]);
DFS(1);
if (!vis[ed]) return -1;
cnt = 0;
for (int i = 1; i <= n; i++)
if (tp[i] == 2 && vis[i]) id[i] = ++cnt, idx[cnt] = i;
int T = n * (d + 1), ED = T + cnt * d;
for (int i = 1; i <= ED; i++) dis[i] = 1e18;
ans = 1e18;
for (int i = 1; i <= n; i++)
if (i == 1 || (tp[i] == 0 && vis[i])) dis[i] = 0, q.push(make_pair(dis[i], i));
while (!q.empty())
{
int u = q.top().second; q.pop();
if (avl[u]) continue;
// cerr << u << " " << dis[u] << "\n";
avl[u] = 1;
if (u <= T)
{
int ly = (u - 1) / n, p = u - ly * n, np = T + id[p] + ly * cnt;
for (int i = head[p]; ~i; i = e[i].nxt)
{
int v = e[i].v + ly * n;
if (dis[v] > dis[u] + e[i].w)
dis[v] = dis[u] + e[i].w, q.push(make_pair(dis[v], v));
}
if (ly != d && tp[p] == 2 && dis[np] > dis[u] / 2)
dis[np] = dis[u] / 2, q.push(make_pair(dis[np], np));
if (p == ed) ans = min(ans, dis[u]);
}
else
{
int ly = (u - T - 1) / cnt, p = idx[u - T - ly * cnt];
for (int i = head[p]; ~i; i = e[i].nxt)
{
int v = e[i].v + (ly + 1) * n;
if (dis[v] > dis[u] + e[i].w)
dis[v] = dis[u] + e[i].w, q.push(make_pair(dis[v], v));
}
}
}
return ans;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 11ms
memory: 10008kb
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.000000000000 1000000000000000000.000000000000 1000000000000000000.000000000000 1000000000000000000.000000000000 -1.000000000000 -1.000000000000 1000000000000000000.000000000000 -1.000000000000 1000000000000000000.000000000000 100...
result:
wrong answer Wrong Answer.
Subtask #2:
score: 0
Wrong Answer
Test #3:
score: 0
Wrong Answer
time: 10ms
memory: 8040kb
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 2890510903.000000000000 1000000000000000000.000000000000 1000000000000000000.000000000000 1000000000000000000.000000000000 1000000000000000000.000000000000 1000000000000000000.000000000000 1000000000000000000.000000000000 1000000000000...
result:
wrong answer Wrong Answer.
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #19:
score: 0
Wrong Answer
time: 15ms
memory: 26800kb
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 2316335021.000000000000 a9100fda0a7059a979d560b8550f715d4ee391ff9b8b680b2f87b26a69ee5a5e
result:
wrong answer Wrong Answer.
Subtask #5:
score: 0
Wrong Answer
Test #24:
score: 0
Wrong Answer
time: 10ms
memory: 10144kb
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 2587209245.000000000000 -1.000000000000 1000000000000000000.000000000000 -1.000000000000 1000000000000000000.000000000000 1000000000000000000.000000000000 -1.000000000000 1000000000000000000.000000000000 1000000000000000000.00000000000...
result:
wrong answer Wrong Answer.
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #6:
0%
Subtask #8:
score: 0
Skipped
Dependency #1:
0%