QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#290248#6527. CyberlandMax_s_xaM0 96ms29892kbC++142.7kb2023-12-24 16:36:512023-12-24 16:36:52

Judging History

你现在查看的是最新测评结果

  • [2023-12-24 16:36:52]
  • 评测
  • 测评结果:0
  • 用时:96ms
  • 内存:29892kb
  • [2023-12-24 16:36:51]
  • 提交

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;
int 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;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 7ms
memory: 10244kb

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: 10344kb

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: 19
Accepted
time: 96ms
memory: 29892kb

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
1099338240.533394813538
a9100fda0a7059a979d560b8550f715d4ee391ff9b8b680b2f87b26a69ee5a5e

result:

ok Correct.

Test #20:

score: -19
Wrong Answer
time: 14ms
memory: 10460kb

input:

100
13 12 30
12
1 0 1 2 0 0 0 1 0 2 1 0 1
0 1 293591903
1 2 934470128
2 3 594097788
3 4 765687740
4 5 33881345
5 6 755464057
6 7 234011373
7 8 377859244
8 9 687794800
9 10 815523317
10 11 970334768
11 12 101468113
817 816 30
548
1 1 0 1 0 1 2 2 1 1 1 2 0 2 2 1 0 1 1 1 2 0 0 2 1 0 1 2 2 0 0 0 0 2 2 0...

output:

a9100fda0a7059a979d560b8550f715d4ee391ff9b8b680b2f87b26a69ee5a5e
101468113.000000000000
684113545.000000000000
1000000000000000000.000000000000
1000000000000000000.000000000000
1000000000000000000.000000000000
1000000000000000000.000000000000
1000000000000000000.000000000000
345085810.000000000000
1...

result:

wrong answer Wrong Answer.

Subtask #5:

score: 0
Wrong Answer

Test #24:

score: 0
Wrong Answer
time: 10ms
memory: 10140kb

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%