답안 #864063

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
864063 2023-10-21T19:55:22 Z VMaksimoski008 봉쇄 시간 (IOI23_closing) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define uniq(x) x.erase(unique(all(x)), x.end())
#define rall(x) x.rbegin(), x.rend()
//#define int long long

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Node = array<ll, 3>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
const double eps = 1e-9;

void setIO() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int n;
vector<vector<pii> > graph;
vector<int> dist1, dist2;

void dfs(int u, int p, int a, int d) {
    if(a == 1) dist1[u] = d;
    else dist2[u] = d;

    for(pii &next : graph[u]) {
        int v = next.first;
        int w = next.second;
        if(v == p) continue;
        dfs(v, u, a, d + w);
    }
}

int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W) {
    n = N;
    graph.clear();
    graph.resize(n);
    dist1.clear();
    dist1.resize(n);
    dist2.clear();
    dist2.resize(n);

    for(int i=0; i<n-1; i++) {
        graph[U[i]].push_back({ V[i], W[i] });
        graph[V[i]].push_back({ U[i], W[i]});
    }

    dfs(X, 0, 1, 0);
    dfs(Y, 0, 2, 0);

    int ans = 0;

    priority_queue<Node, vector<Node>, greater<Node> > pq;
    for(int i=0; i<n; i++) pq.push({ min(dist1[i], dist2[i]), 1, i });

    while(!pq.empty()) {
        int u = pq.top().at(2);
        int t = pq.top().at(1);
        ll d = pq.top().at(0);
        pq.pop();

        if(d <= K) {
            ans++;
            K -= d;
            if(t == 1) {
                pq.push({ max(dist1[u], dist2[u]), 2, i });
            }
        }
    }

    return ans;
}

// int32_t main() {
//     setIO();

//     

//     return 0;
// }

Compilation message

closing.cpp: In function 'int max_score(int, int, int, ll, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:79:55: error: 'i' was not declared in this scope
   79 |                 pq.push({ max(dist1[u], dist2[u]), 2, i });
      |                                                       ^
closing.cpp:79:58: error: no matching function for call to 'std::priority_queue<std::array<long long int, 3>, std::vector<std::array<long long int, 3> >, std::greater<std::array<long long int, 3> > >::push(<brace-enclosed initializer list>)'
   79 |                 pq.push({ max(dist1[u], dist2[u]), 2, i });
      |                                                          ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from closing.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::array<long long int, 3>; _Sequence = std::vector<std::array<long long int, 3> >; _Compare = std::greater<std::array<long long int, 3> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::array<long long int, 3>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::array<long long int, 3>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::array<long long int, 3>; _Sequence = std::vector<std::array<long long int, 3> >; _Compare = std::greater<std::array<long long int, 3> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::array<long long int, 3>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::array<long long int, 3>, std::vector<std::array<long long int, 3> >, std::greater<std::array<long long int, 3> > >::value_type&&' {aka 'std::array<long long int, 3>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~