답안 #1029964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1029964 2024-07-21T14:54:51 Z mindiyak 봉쇄 시간 (IOI23_closing) C++17
0 / 100
115 ms 30720 KB
#include "closing.h"
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<int, int> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define nl endl
#define S second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;

priority_queue<ll> arr;
vector<vpi> paths(2e5+5);

void dfs(int pos,int cost,int prev){
    for(pi edge:paths[pos]){
        if(edge.F == prev)continue;
        // cout << pos << " " << edge.F << " " << edge.S << " " << cost << " " << isX << endl;
        arr.push(-(edge.S+cost));
        dfs(edge.F,edge.S+cost,pos);
    }
}

int max_score(int N, int X, int Y, ll K,vi U, vi V, vi W)
{
    arr = priority_queue<ll>();
    paths = vector<vpi>(2e5+5);

    FOR(i,0,N-1){
        paths[U[i]].pb({V[i],W[i]});
        paths[V[i]].pb({U[i],W[i]});
    }

    // vi visited(2e5+5);
    dfs(X,0,-1);
    dfs(Y,0,-1);

    int ans = 2;

    while(K > 0){
        if(arr.empty())break;

        ll a = -arr.top();arr.pop();

        if(K >= a){
            K-=a;
            ans++;
        }else{
            break;
        }
    }

    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 9816 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 115 ms 30720 KB 1st lines differ - on the 1st token, expected: '451', found: '400000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9816 KB Output is correct
2 Incorrect 3 ms 9820 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9816 KB Output is correct
2 Incorrect 3 ms 9820 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9816 KB Output is correct
2 Incorrect 3 ms 9820 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 9816 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 9816 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 9816 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 9816 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 9816 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -