Submission #988577

# Submission time Handle Problem Language Result Execution time Memory
988577 2024-05-25T07:57:20 Z Gray Closing Time (IOI23_closing) C++17
0 / 100
75 ms 25524 KB
#include "closing.h"

#include <bits/stdc++.h>
#include <functional>
#include <queue>
#define ll long long
#define ff first
#define ss second
#define ln endl
using namespace std;
vector<vector<int>> A;
ll n, x, y, k;
vector<pair<ll, pair<ll, ll>>> edge;
ll dijkstra(){
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> que;
    que.push({0, x});
    que.push({0, y});
    vector<bool> reachable(n, 0);
    while (!que.empty()){
        auto cur = que.top();
        que.pop();
        if (reachable[cur.ss] or k<cur.ff){
            continue;
        }
        // cout << cur.ss << ln;
        reachable[cur.ss]=1;
        k-=cur.ff;
        for (auto i:A[cur.ss]){
            auto v = edge[i].ss.ff^edge[i].ss.ss^cur.ss;
            if (reachable[v] or cur.ff+edge[i].ff>k) continue;
            que.push({cur.ff+edge[i].ff, v});
        }
    }
    ll ans=0;
    for (ll i=0; i<n; i++) {
        if (reachable[i]) {
            // cout << i << ln;
            ans++;
        }
    }
    return ans;
}
int max_score(int N, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    A.resize(N);
    n=N; x=X; y=Y; k=K;
    for (ll i=0; i<n-1; i++){
        A[U[i]].push_back(i);
        A[V[i]].push_back(i);
        edge.push_back({W[i],{V[i], U[i]}});
    }
    return dijkstra();
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 75 ms 25016 KB Output is correct
2 Correct 75 ms 25524 KB Output is correct
3 Runtime error 43 ms 8008 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -