Submission #1201268

#TimeUsernameProblemLanguageResultExecution timeMemory
1201268PagodePaivaClosing Time (IOI23_closing)C++20
Compilation error
0 ms0 KiB
#include "closing.h"
#include<bits/stdc++.h>

using namespace std;
const int N = 200010;

vector <pair <int, int>> g[N];
int mark[N];

int max_score(int n, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W){
    for(int i = 0;i < n-1;i++){
        g[U[i]].push_back({V[i], W[i]});
        g[V[i]].push_back({U[i], W[i]});
    }
    int ans = 0;
    priority_queue <int> pq;
    for(auto [v, w] : g[X]){
        pq.push({-w, v});
    }
    for(auto [v, w] : g[Y]){
        pq.push({-w, v});
    }
    int ans = 0, sum = 0;;
    while(!pq.empty()){
        auto [w, v] = pq.top();
        pq.pop();
        if(mark[v])
            continue;
        w *= -1;
        if(sum+w > k){
            return ans;
        }
        sum += w;
        ans++;
        mark[v] = 1;
        for(auto [x, ww] : g[v]){
            if(mark[x])
                continue;
            pq.push({-(ww+w), x});
        }
    }
    return ans;
}

Compilation message (stderr)

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:19:16: error: no matching function for call to 'std::priority_queue<int>::push(<brace-enclosed initializer list>)'
   19 |         pq.push({-w, v});
      |         ~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/11/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:86,
                 from closing.cpp:2:
/usr/include/c++/11/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::less<int>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = int]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/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 = int; _Sequence = std::vector<int>; _Compare = std::less<int>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = int]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<int>::value_type&&' {aka 'int&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
closing.cpp:22:16: error: no matching function for call to 'std::priority_queue<int>::push(<brace-enclosed initializer list>)'
   22 |         pq.push({-w, v});
      |         ~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/11/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:86,
                 from closing.cpp:2:
/usr/include/c++/11/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::less<int>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = int]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/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 = int; _Sequence = std::vector<int>; _Compare = std::less<int>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = int]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<int>::value_type&&' {aka 'int&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
closing.cpp:24:9: error: redeclaration of 'int ans'
   24 |     int ans = 0, sum = 0;;
      |         ^~~
closing.cpp:16:9: note: 'int ans' previously declared here
   16 |     int ans = 0;
      |         ^~~
closing.cpp:26:14: error: cannot decompose non-array non-class type 'int'
   26 |         auto [w, v] = pq.top();
      |              ^~~~~~
closing.cpp:31:20: error: 'k' was not declared in this scope
   31 |         if(sum+w > k){
      |                    ^
closing.cpp:40:20: error: no matching function for call to 'std::priority_queue<int>::push(<brace-enclosed initializer list>)'
   40 |             pq.push({-(ww+w), x});
      |             ~~~~~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:86,
                 from closing.cpp:2:
/usr/include/c++/11/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::less<int>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = int]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/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 = int; _Sequence = std::vector<int>; _Compare = std::less<int>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = int]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<int>::value_type&&' {aka 'int&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~