답안 #1016310

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1016310 2024-07-07T18:21:51 Z Andrey 봉쇄 시간 (IOI23_closing) C++17
8 / 100
89 ms 37716 KB
#include "closing.h"
#include<bits/stdc++.h>
#include <vector>
using namespace std;

long long n,x,y,k;
vector<pair<long long,long long>> haha[200001];
vector<long long> bruh(200001);
vector<long long> wow(200001);

void dfs(long long a, long long t, long long d, bool yeah) {
    if(yeah) {
        bruh[a] = d;
    }
    else {
        wow[a] = d;
    }
    for(pair<long long,long long> v: haha[a]) {
        if(v.first != t) {
            dfs(v.first,a,d+v.second,yeah);
        }
    }
}

int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
    n = N;
    x = X;
    y = Y;
    k = K;
    for(int i = 0; i < n; i++) {
        haha[i].clear();
    }
    for(long long i = 0; i < n-1; i++) {
        haha[U[i]].push_back({V[i],W[i]});
        haha[V[i]].push_back({U[i],W[i]});
    }
    long long ans = 0;
    dfs(x,-1,0,true);
    dfs(y,-1,0,false);
    vector<long long> wut(n);
    for(long long i = 0; i < n; i++) {
        wut[i] = min(bruh[i],wow[i]);
    }
    sort(wut.begin(),wut.end());
    long long sb = 0;
    for(long long i = 0; i < wut.size(); i++) {
        sb+=wut[i];
        if(sb > k) {
            break;
        }
        ans++;
    }
    return ans;
}

Compilation message

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:46:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(long long i = 0; i < wut.size(); i++) {
      |                          ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8280 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 29184 KB Output is correct
2 Correct 89 ms 37716 KB Output is correct
3 Correct 62 ms 13392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8028 KB Output is correct
2 Incorrect 2 ms 8028 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8028 KB Output is correct
2 Incorrect 2 ms 8028 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8028 KB Output is correct
2 Incorrect 2 ms 8028 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8280 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8280 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8280 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8280 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8280 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -