Submission #1201266

#TimeUsernameProblemLanguageResultExecution timeMemory
1201266PagodePaivaClosing Time (IOI23_closing)C++20
Compilation error
0 ms0 KiB
#include "closing.h" #include<bits/stdc++.h> using namespace std; const int N = 2000010; vector <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:14:26: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   14 |         g[U[i]].push_back({V[i], W[i]});
      |         ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from closing.h:1,
                 from closing.cpp:2:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
closing.cpp:15:26: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   15 |         g[V[i]].push_back({U[i], W[i]});
      |         ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from closing.h:1,
                 from closing.cpp:2:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
closing.cpp:19:14: error: cannot decompose non-array non-class type 'int'
   19 |     for(auto [v, w] : g[X]){
      |              ^~~~~~
closing.cpp:20:16: error: no matching function for call to 'std::priority_queue<int>::push(<brace-enclosed initializer list>)'
   20 |         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:3:
/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:14: error: cannot decompose non-array non-class type 'int'
   22 |     for(auto [v, w] : g[Y]){
      |              ^~~~~~
closing.cpp:23:16: error: no matching function for call to 'std::priority_queue<int>::push(<brace-enclosed initializer list>)'
   23 |         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:3:
/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:25:9: error: redeclaration of 'int ans'
   25 |     int ans = 0, sum = 0;;
      |         ^~~
closing.cpp:17:9: note: 'int ans' previously declared here
   17 |     int ans = 0;
      |         ^~~
closing.cpp:27:14: error: cannot decompose non-array non-class type 'int'
   27 |         auto [w, v] = pq.top();
      |              ^~~~~~
closing.cpp:32:20: error: 'k' was not declared in this scope
   32 |         if(sum+w > k){
      |                    ^
closing.cpp:41:20: error: no matching function for call to 'std::priority_queue<int>::push(<brace-enclosed initializer list>)'
   41 |             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:3:
/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)
      |            ~~~~~~~~~~~~~^~~