# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
939424 | Trisanu_Das | Closing Time (IOI23_closing) | C++17 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forn(i,n) for(int i=0; i<(n); ++i)
#define pb push_back
#define pi pair<ll,ll>
#define f first
#define s second
#define vii(a,n) vector<int> a(n); forn(i,n) cin>>a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
int max_score(int n, int x, int y, ll k, vector<int>u, vector<int>v, vector<int>w) {
vector<vector<pi>> adj(n);
vector<map<int,int>> vis(n+1), dist(n+1);
forn(i,n-1) adj[u[i]].pb({v[i],w[i]}), adj[v[i]].pb({u[i],w[i]});
queue<int> q;
dist[x][x]=dist[y][y]=0;
for (int z : {x, y}) {
q.push(z);
while (q.size()) {
int u = q.front(); q.pop();
for(auto&e:adj[u]) {
int v=e.f, w=e.s;
if (dist[z].count(v)) continue;
dist[z][v]=dist[z][u]+w;
q.push(v);
}
}
}
int ans=0;
set<pair<int,pi>> q;
q.insert({0,{x,x}});
q.insert({0,{y,y}});
vector<int> c(n);
vector<map<int,pair<int,pi>>> last(n);
vector<map<int,int>> in(n);
last[x][x]={0,{x,x}};
last[y][y]={0,{y,y}};
in[x][x]=in[y][y]=1;
while (q.size()) {
auto it = *q.begin(); q.erase(q.begin());
if (it.f > k) return ans;
int d = it.f, u = it.s.f, z = it.s.s;
++ans;
k-=d;
c[u] = max(c[u], dist[z][u]);
vis[z][u]=1;
in[z][u]=0;
for (int z : {x, y}) {
if (in[z][u]) {
q.erase(last[z][u]);
q.insert({max(dist[z][u]-c[u],0ll),{u,z}});
last[z][u] = {max(dist[z][u]-c[u],0ll),{u,z}};
}
}
for(auto&e:adj[u]) {
int v=e.f;
if (vis[z][v]) continue;
int t = dist[z][v];
t = max(t-c[v],0ll);
q.insert({t,{v,z}});
in[z][v]=1;
last[z][v]={t,{v,z}};
}
}
return ans;
}
Compilation message (stderr)
closing.cpp: In function 'int max_score(int, int, int, ll, std::vector<int>, std::vector<int>, std::vector<int>)': closing.cpp:36:21: error: conflicting declaration 'std::set<std::pair<int, std::pair<long long int, long long int> > > q' 36 | set<pair<int,pi>> q; | ^ closing.cpp:19:14: note: previous declaration as 'std::queue<int> q' 19 | queue<int> q; | ^ closing.cpp:37:5: error: 'class std::queue<int>' has no member named 'insert' 37 | q.insert({0,{x,x}}); | ^~~~~~ closing.cpp:38:5: error: 'class std::queue<int>' has no member named 'insert' 38 | q.insert({0,{y,y}}); | ^~~~~~ closing.cpp:48:18: error: 'class std::queue<int>' has no member named 'begin' 48 | auto it = *q.begin(); q.erase(q.begin()); | ^~~~~ closing.cpp:48:29: error: 'class std::queue<int>' has no member named 'erase' 48 | auto it = *q.begin(); q.erase(q.begin()); | ^~~~~ closing.cpp:48:37: error: 'class std::queue<int>' has no member named 'begin' 48 | auto it = *q.begin(); q.erase(q.begin()); | ^~~~~ closing.cpp:53:6: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::vector<int>') 53 | c[u] = max(c[u], dist[z][u]); | ^ In file included from /usr/include/c++/10/vector:67, from closing.h:1, from closing.cpp:1: /usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/10/bits/stl_vector.h:1043:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'} 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1061 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/10/bits/stl_vector.h:1061:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'} 1061 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ closing.cpp:53:17: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::vector<int>') 53 | c[u] = max(c[u], dist[z][u]); | ^ In file included from /usr/include/c++/10/vector:67, from closing.h:1, from closing.cpp:1: /usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/10/bits/stl_vector.h:1043:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'} 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1061 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/10/bits/stl_vector.h:1061:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'} 1061 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ closing.cpp:53:27: error: 'z' was not declared in this scope 53 | c[u] = max(c[u], dist[z][u]); | ^ closing.cpp:58:16: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::map<int, int> >, std::map<int, int> >::value_type' {aka 'std::map<int, int>'} and 'std::vector<int>') 58 | if (in[z][u]) { | ^ In file included from /usr/include/c++/10/map:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81, from closing.cpp:2: /usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]' 492 | operator[](const key_type& __k) | ^~~~~~~~ /usr/include/c++/10/bits/stl_map.h:492:34: note: no known conversion for argument 1 from 'std::vector<int>' to 'const key_type&' {aka 'const int&'} 492 | operator[](const key_type& __k) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]' 512 | operator[](key_type&& __k) | ^~~~~~~~ /usr/include/c++/10/bits/stl_map.h:512:29: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::map<int, int>::key_type&&' {aka 'int&&'} 512 | operator[](key_type&& __k) | ~~~~~~~~~~~^~~ closing.cpp:59:11: error: 'class std::queue<int>' has no member named 'erase' 59 | q.erase(last[z][u]); | ^~~~~ closing.cpp:59:24: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::map<int, std::pair<int, std::pair<long long int, long long int> > > >, std::map<int, std::pair<int, std::pair<long long int, long long int> > > >::value_type' {aka 'std::map<int, std::pair<int, std::pair<long long int, long long int> > >'} and 'std::vector<int>') 59 | q.erase(last[z][u]); | ^ In file included from /usr/include/c++/10/map:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81, from closing.cpp:2: /usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = std::pair<int, std::pair<long long int, long long int> >; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, std::pair<int, std::pair<long long int, long long int> > > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::pair<int, std::pair<long long int, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]' 492 | operator[](const key_type& __k) | ^~~~~~~~ /usr/include/c++/10/bits/stl_map.h:492:34: note: no known conversion for argument 1 from 'std::vector<int>' to 'const key_type&' {aka 'const int&'} 492 | operator[](const key_type& __k) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = int; _Tp = std::pair<int, std::pair<long long int, long long int> >; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, std::pair<int, std::pair<long long int, long long int> > > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::pair<int, std::pair<long long int, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]' 512 | operator[](key_type&& __k) | ^~~~~~~~ /usr/include/c++/10/bits/stl_map.h:512:29: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::map<int, std::pair<int, std::pair<long long int, long long int> > >::key_type&&' {aka 'int&&'} 512 | operator[](key_type&& __k) | ~~~~~~~~~~~^~~ closing.cpp:60:11: error: 'class std::queue<int>' has no member named 'insert' 60 | q.insert({max(dist[z][u]-c[u],0ll),{u,z}}); | ^~~~~~ closing.cpp:60:30: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::map<int, int> >, std::map<int, int> >::value_type' {aka 'std::map<int, int>'} and 'std::vector<int>') 60 | q.insert({max(dist[z][u]-c[u],0ll),{u,z}}); | ^ In file included from /usr/include/c++/10/map:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81, from closing.cpp:2: /usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]' 492 | operator[](const key_type& __k) | ^~~~~~~~ /usr/include/c++/10/bits/stl_map.h:492:34: note: no known conversion for argument 1 from 'std::vector<int>' to 'const key_type&' {aka 'const int&'} 492 | operator[](const key_type& __k) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]' 512 | operator[](key_type&& __k) | ^~~~~~~~ /usr/include/c++/10/bits/stl_map.h:512:29: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::map<int, int>::key_type&&' {aka 'int&&'} 512 | operator[](key_type&& __k) | ~~~~~~~~~~~^~~ closing.cpp:60:35: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::vector<int>') 60 | q.insert({max(dist[z][u]-c[u],0ll),{u,z}}); | ^ In file included from /usr/include/c++/10/vector:67, from closing.h:1, from closing.cpp:1: /usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/10/bits/stl_vector.h:1043:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'} 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1061 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/10/bits/stl_vector.h:1061:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'} 1061 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ closing.cpp:61:16: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::map<int, std::pair<int, std::pair<long long int, long long int> > > >, std::map<int, std::pair<int, std::pair<long long int, long long int> > > >::value_type' {aka 'std::map<int, std::pair<int, std::pair<long long int, long long int> > >'} and 'std::vector<int>') 61 | last[z][u] = {max(dist[z][u]-c[u],0ll),{u,z}}; | ^ In file included from /usr/include/c++/10/map:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81, from closing.cpp:2: /usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = std::pair<int, std::pair<long long int, long long int> >; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, std::pair<int, std::pair<long long int, long long int> > > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::pair<int, std::pair<long long int, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]' 492 | operator[](const key_type& __k) | ^~~~~~~~ /usr/include/c++/10/bits/stl_map.h:492:34: note: no known conversion for argument 1 from 'std::vector<int>' to 'const key_type&' {aka 'const int&'} 492 | operator[](const key_type& __k) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = int; _Tp = std::pair<int, std::pair<long long int, long long int> >; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, std::pair<int, std::pair<long long int, long long int> > > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::pair<int, std::pair<long long int, long long int> >; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]' 512 | operator[](key_type&& __k) | ^~~~~~~~ /usr/include/c++/10/bits/stl_map.h:512:29: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::map<int, std::pair<int, std::pair<long long int, long long int> > >::key_type&&' {aka 'int&&'} 512 | operator[](key_type&& __k) | ~~~~~~~~~~~^~~ closing.cpp:61:34: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::map<int, int> >, std::map<int, int> >::value_type' {aka 'std::map<int, int>'} and 'std::vector<int>') 61 | last[z][u] = {max(dist[z][u]-c[u],0ll),{u,z}}; | ^ In file included from /usr/include/c++/10/map:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81, from closing.cpp:2: /usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]' 492 | operator[](const key_type& __k) | ^~~~~~~~ /usr/include/c++/10/bits/stl_map.h:492:34: note: no known conversion for argument 1 from 'std::vector<int>' to 'const key_type&' {aka 'const int&'} 492 | operator[](const key_type& __k) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]' 512 | operator[](key_type&& __k) | ^~~~~~~~ /usr/include/c++/10/bits/stl_map.h:512:29: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::map<int, int>::key_type&&' {aka 'int&&'} 512 | operator[](key_type&& __k) | ~~~~~~~~~~~^~~ closing.cpp:61:39: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::vector<int>') 61 | last[z][u] = {max(dist[z][u]-c[u],0ll),{u,z}}; | ^ In file included from /usr/include/c++/10/vector:67, from closing.h:1, from closing.cpp:1: /usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/10/bits/stl_vector.h:1043:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'} 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1061 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/10/bits/stl_vector.h:1061:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int