답안 #1037893

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1037893 2024-07-29T09:50:18 Z Zicrus 봉쇄 시간 (IOI23_closing) C++17
8 / 100
94 ms 28964 KB
#include <bits/stdc++.h>
#include "closing.h"
using namespace std;

typedef long long ll;

int max_score(int n, int x, int y, ll k, vector<int> u, vector<int> v, vector<int> w) {
    priority_queue<pair<ll, ll>> finalQ;
    vector<vector<pair<ll, ll>>> adj(n);
    for (int i = 0; i < w.size(); i++) {
        adj[u[i]].push_back({-w[i], v[i]});
        adj[v[i]].push_back({-w[i], u[i]});
    }

    vector<ll> distX(n, 1ll << 62ll), distY(n, 1ll << 62ll);
    vector<bool> vstX(n), vstY(n);
    priority_queue<pair<ll, ll>> q;
    distX[x] = distY[y] = 0;
    q.push({0, x});
    while (!q.empty()) {
        ll node = q.top().second; q.pop();
        if (vstX[node]) continue;
        vstX[node] = true;
        for (auto &e : adj[node]) {
            distX[e.second] = min(distX[e.second], distX[node] - e.first);
            q.push({-distX[e.second], e.second});
        }
    }
    q.push({0, y});
    while (!q.empty()) {
        ll node = q.top().second; q.pop();
        if (vstY[node]) continue;
        vstY[node] = true;
        for (auto &e : adj[node]) {
            distY[e.second] = min(distY[e.second], distY[node] - e.first);
            q.push({-distY[e.second], e.second});
        }
    }

    for (int i = 0; i < n; i++) {
        finalQ.push({-min(distX[i], distY[i]), i});
    }

    ll res = 0;
    while (!finalQ.empty()) {
        ll dist = -finalQ.top().first; finalQ.pop();
        if (dist > k) return res;
        k -= dist;
        res++;
    }
    return res;
}

Compilation message

closing.cpp: In function 'int max_score(int, int, int, ll, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:10:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int i = 0; i < w.size(); i++) {
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 94 ms 28964 KB Output is correct
2 Correct 88 ms 28500 KB Output is correct
3 Correct 61 ms 2860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -