QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#670849#6527. Cyberlandmakrav0 287ms264152kbC++203.0kb2024-10-24 04:53:422024-10-24 04:53:43

Judging History

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

  • [2024-10-24 04:53:43]
  • 评测
  • 测评结果:0
  • 用时:287ms
  • 内存:264152kb
  • [2024-10-24 04:53:42]
  • 提交

answer

#include "cyberland.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int KC = 60;

#define EL pair<__int128_t, int>
#define pb push_back

struct pq_promax {
    priority_queue<EL, vector<EL>, greater<>> add_, del_;
    // this is PQ for minimum, if you want maximum delete greater<>
    pq_promax() = default;
    void add(EL x) {
        add_.push(x);
    }
    void del(EL x) {
        del_.push(x);
    }
    EL get() {
        while (del_.size() && del_.top() == add_.top()) del_.pop(), add_.pop();
        if (add_.size()) return add_.top();
        return make_pair((__int128_t)-1, -1);
    }
};

double solve(int32_t N, int32_t M, int32_t K, int32_t H, vector<int32_t> x, vector<int32_t> y, vector<int32_t> c, vector<int32_t> arr) {
    K = min(K, KC);
    vector<vector<pair<int, __int128_t>>> g(N * (K + 1));
    auto encode = [&](int vt, int lvl) {
        return lvl * N + vt;
    };
    for (int i = 0; i < N; i++) {
        if (arr[i] == 2) {
            for (int j = 0; j < K; j++) {
                g[encode(i, j)].push_back({encode(i, j + 1), 0});
            }
        }
    }
    vector<ll> pw2(K + 1, 1);
    for (int i = 1; i <= K; i++) pw2[i] = pw2[i - 1] * 2;
    for (int i = 0; i < M; i++) {
        for (int lvl = 0; lvl <= K; lvl++) {
            if (x[i] == H || y[i] == H && lvl > 0) continue;
            g[encode(x[i], lvl)].emplace_back(encode(y[i], lvl), c[i] * (__int128_t)1 * pw2[K - lvl]);
            g[encode(y[i], lvl)].emplace_back(encode(x[i], lvl), c[i] * (__int128_t)1 * pw2[K - lvl]);
        }
    }

    pq_promax pq;
    vector<__int128_t> dist(N * (K + 1), -1);
    vector<int> used(N * (K + 1), 0);
    dist[H] = 0;
    pq.add(make_pair((__int128_t)0, H));
    while (true) {
        auto rs = pq.get(); 
        //cout << (ll)rs.first << ' ' << rs.second << endl;
        if (rs.second == -1) break;
        pq.del(rs);
        used[rs.second] = 1;
        for (auto [v, w] : g[rs.second]) {
            if (!used[v] && (dist[v] == -1 || dist[v] > rs.first + w)) {
                if (dist[v] != -1) {
                    pq.del({dist[v], v});
                }
                dist[v] = rs.first + w;
                pq.add(make_pair(dist[v], v));
            }
        }
    }   

    vector<int> us2(N);
    us2[H] = 1;
    vector<vector<int>> GR(N);
    for (int i = 0; i < M; i++) {
      GR[x[i]].pb(y[i]);
      GR[y[i]].pb(x[i]);
    }
    auto dfs = [&](int v, auto&&self) -> void {
        us2[v] = 1;
        for (int u : GR[v]) {
          if (!us2[u]) self(u, self);
        }
    };
    dfs(0, dfs);
    vector<int> edps = {0};
    for (int i = 0; i < N; i++) {
      if (us2[i] && arr[i] == 0) edps.pb(i);
    }
    double ans = 1e18;
    double dvd = pw2[K];
    for (int lvl = K; lvl >=0; lvl--) {
        for (int vt : edps) {
            if (dist[encode(vt, lvl)] != -1) {
              ans = min(ans, dist[encode(vt, lvl)] / dvd); 
            }
        }
    }
    return (abs(ans - 1e18) > 1 ? ans : -1);
}
 

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 25ms
memory: 3812kb

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
-1.000000000000000
38641.000000000000000
11947.000000000000000
27361.000000000000000
-1.000000000000000
-1.000000000000000
9991.000000000000000
-1.000000000000000
-1.000000000000000
15754.000000000000000
-1.000000000000000
-1.000000000...

result:

wrong answer Wrong Answer.

Subtask #2:

score: 0
Wrong Answer

Test #3:

score: 0
Wrong Answer
time: 101ms
memory: 7980kb

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
-1.000000000000000
-1.000000000000000
-1.000000000000000
-1.000000000000000
-1.000000000000000
-1.000000000000000
-1.000000000000000
-1.000000000000000
-1.000000000000000
-1.000000000000000
-1.000000000000000
-1.000000000000000
-1.0000...

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: 287ms
memory: 264152kb

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

result:

wrong answer Wrong Answer.

Subtask #5:

score: 0
Wrong Answer

Test #24:

score: 0
Wrong Answer
time: 110ms
memory: 7492kb

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.000000000000000
-1.000000000000000
3649459267.000000000000000
-1.000000000000000
5454642919.000000000000000
3957060220.000000000000000
-1.000000000000000
1779591226.000000000000000
819344528.000000000000000
3336087675.000000...

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%