답안 #988578

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
988578 2024-05-25T08:01:06 Z Gray 봉쇄 시간 (IOI23_closing) C++17
8 / 100
77 ms 20888 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.assign(N, vector<int>());
    edge.resize(N-1);
    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[i]={W[i],{V[i], U[i]}};
    }
    return dijkstra();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 20888 KB Output is correct
2 Correct 77 ms 20800 KB Output is correct
3 Correct 40 ms 2900 KB Output is correct
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -