답안 #1010212

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1010212 2024-06-28T13:19:51 Z thinknoexit 봉쇄 시간 (IOI23_closing) C++17
0 / 100
70 ms 29012 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
bool vis[200200];
vector<pair<int, int>> adj[200200];
ll dx[200200], dy[200200];
void dfs(int v, int p, ll dis[]) {
    for (auto& [x, w] : adj[v]) {
        if (x == p) continue;
        dis[x] = dis[v] + w;
        dfs(x, v, dis);
    }
}
int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W) {
    n = N;
    for (int i = 0;i < n - 1;i++) {
        adj[U[i]].push_back({ V[i], W[i] });
        adj[V[i]].push_back({ U[i], W[i] });
    }
    dx[X] = dy[Y] = 0;
    dfs(X, -1, dx);
    dfs(Y, -1, dy);
    pq.push({ 0, X }), vis[X] = 1;
    pq.push({ 0, Y }), vis[Y] = 1;
    int cnt = 0;
    while (!pq.empty()) {
        auto x = pq.top();
        int v = pq.top().second;
        ll w = pq.top().first;
        pq.pop();
        if (K - w < 0) break;
        K -= w;
        cnt++;
        for (auto& [x, w] : adj[v]) {
            if (vis[x]) continue;
            vis[x] = 1;
            pq.push({ min(dx[x], dy[x]), x });
        }
    }
    for (int i = 0;i < n;i++) adj[i].clear(), vis[i] = 0;
    return cnt;
}

Compilation message

closing.cpp: In function 'int max_score(int, int, int, ll, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:30:14: warning: variable 'x' set but not used [-Wunused-but-set-variable]
   30 |         auto x = pq.top();
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8028 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 24792 KB Output is correct
2 Correct 70 ms 29012 KB Output is correct
3 Incorrect 37 ms 10456 KB 2nd lines differ - on the 1st token, expected: '38', found: '42'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8024 KB Output is correct
2 Incorrect 2 ms 8024 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8024 KB Output is correct
2 Incorrect 2 ms 8024 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8024 KB Output is correct
2 Incorrect 2 ms 8024 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8028 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8028 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8028 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8028 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8028 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -