Submission #981879

# Submission time Handle Problem Language Result Execution time Memory
981879 2024-05-13T15:57:49 Z Maaxle Cyberland (APIO23_cyberland) C++17
8 / 100
22 ms 6748 KB
#include "cyberland.h"
#include <bits/stdc++.h>

#define range(it, a, b) for (ll it = a; it < b; it++)
#define all(x) begin(x), end(x)
#define ll long long
#define ull unsigned long long
#define INF64 ((ll) 1 << 62)
#define INF32 (1 << 30)
#define mset multiset
#define uset unordered_set
#define umap unordered_map 
#define pqueue priority_queue 
#define ptr(A) shared_ptr<A>

using namespace std;

struct TPos {
    int i, w;
};
bool operator < (const TPos& a, const TPos& b) {
    return a.w > b.w;
}

vector<vector<TPos>> adj;
vector<int> a;
vector<double> memo;

// void dijkstra() {
//     pqueue<TPos> pq;
//     pq.push({0, 0});

//     TPos t, nt;
//     while (!pq.empty()) {
//         t = pq.top();
//         pq.pop();

//         if (memo[t.i] < t.w)
//             continue;
//         memo[t.i] = t.w;

//         for (TPos& it : adj[t.i]) {
//             nt = {it.i, (a[it.i] == 0 ? 0 : memo[t.i] + it.w)};
//             if (memo[it.i] > nt.w)
//                 pq.push(nt);
//         }
//     }
// }

void dfs(int i, int& H, double w) {
    memo[i] = w;
    if (i == H) return;

    for (TPos& it : adj[i]) {
        if (memo[it.i] == INF64) 
            dfs(it.i, H, (a[i] == 0 ? 0 : memo[i])+it.w);
    }
}

double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
    adj.clear();
    adj.resize(N);

    memo.clear();
    memo.resize(N, INF64);

    a = arr;

    range(i, 0, M) {
        adj[x[i]].push_back({y[i], c[i]});
        adj[y[i]].push_back({x[i], c[i]});
    }

    dfs(0, H, 0);
    return memo[H];
}
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 600 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 604 KB Correct.
2 Correct 18 ms 600 KB Correct.
3 Correct 17 ms 604 KB Correct.
4 Correct 18 ms 504 KB Correct.
5 Correct 17 ms 600 KB Correct.
6 Correct 14 ms 1440 KB Correct.
7 Correct 19 ms 1440 KB Correct.
8 Correct 8 ms 2396 KB Correct.
9 Correct 17 ms 348 KB Correct.
10 Correct 17 ms 488 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 348 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 6748 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 544 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 600 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 604 KB Double 4.61169e+18 violates the range [-1, 1e+18]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 604 KB Double 4.61169e+18 violates the range [-1, 1e+18]
2 Halted 0 ms 0 KB -