답안 #839896

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
839896 2023-08-30T20:14:09 Z mohammad_kilani 봉쇄 시간 (IOI23_closing) C++17
8 / 100
99 ms 33320 KB
#include "closing.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;

int n , x , y;

long long k;
const int N = 200010;

vector< pair< int , int > > g[N];

long long a[N] , b[N];

void DFS(int node,int prnt,long long *a,long long dist){
    a[node] = dist;
    for(int i = 0 ;i < (int)g[node].size();i++){
        if(g[node][i].first != prnt)
            DFS(g[node][i].first , node , a , dist + g[node][i].second);
    }
}

int max_score(int N, int X, int Y, long long K,std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    for(int i = 0;i < n;i++) g[i].clear();
    n = N, x = X , y = Y , k = K;

    for(int i = 0 ;i < (int)U.size();i++){
        g[U[i]].push_back(make_pair(V[i] , W[i]));
        g[V[i]].push_back(make_pair(U[i] , W[i]));
    }
    DFS(X , -1 , a , 0);
    DFS(Y, - 1, b , 0);

    priority_queue < long long > q;
    for(int i = 0 ;i < n;i++){
        q.push(-min(a[i] , b[i]));
    }
    int ans = 0;
    while(!q.empty()){
        k += q.top();
        q.pop();
        if(k < 0) break;
        ans++;
    }

    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 27820 KB Output is correct
2 Correct 99 ms 33320 KB Output is correct
3 Correct 53 ms 7484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -