# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1250920 | guymmk | Triple Peaks (IOI25_triples) | C++20 | Compilation error | 0 ms | 0 KiB |
// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
#include "triples.h"
using namespace std;
vector<int> v;
int n;
set<vector<int>>s;
inline void is_triple(vector<int>&g){
sort(g.begin(),g.end());
if(g[0]==g[1]||g[0]==g[2]||g[1]==g[2]||g[0]<0||g[2]>=n)return;
vector<int>a,b;
a={g[1]-g[0],g[2]-g[0],g[2]-g[1]};
b={v[g[0]],v[g[1]],v[g[2]]};
sort(a.begin(),a.end());
sort(b.begin(),b.end());
if(a==b)s.insert(g);
}
long long count_triples(vector<int> hsh) {
v=hsh;
s.clear();
int ans=0;
n=v.size();
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
is_triple({i,j,i+v[i]});
is_triple({i,j,j+v[i]});
is_triple({i,j,i+v[j]});
is_triple({i,j,j+v[j]});
is_triple({i,j,i-v[i]});
is_triple({i,j,j-v[i]});
is_triple({i,j,i-v[j]});
is_triple({i,j,j-v[j]});
}
}return s.size();
}
vector<int> construct_range(int M, int K) {
return {1, 1, 1};
}
Compilation message (stderr)
triples.cpp: In function 'long long int count_triples(std::vector<int>)': triples.cpp:26:24: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>' 26 | is_triple({i,j,i+v[i]}); | ~~~~~~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:67, from /usr/include/c++/11/functional:62, from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/11/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from triples.cpp:3: /usr/include/c++/11/bits/stl_vector.h:625:7: note: after user-defined conversion: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 625 | vector(initializer_list<value_type> __l, | ^~~~~~ triples.cpp:9:35: note: initializing argument 1 of 'void is_triple(std::vector<int>&)' 9 | inline void is_triple(vector<int>&g){ | ~~~~~~~~~~~~^ triples.cpp:27:24: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>' 27 | is_triple({i,j,j+v[i]}); | ~~~~~~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:67, from /usr/include/c++/11/functional:62, from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/11/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from triples.cpp:3: /usr/include/c++/11/bits/stl_vector.h:625:7: note: after user-defined conversion: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 625 | vector(initializer_list<value_type> __l, | ^~~~~~ triples.cpp:9:35: note: initializing argument 1 of 'void is_triple(std::vector<int>&)' 9 | inline void is_triple(vector<int>&g){ | ~~~~~~~~~~~~^ triples.cpp:28:24: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>' 28 | is_triple({i,j,i+v[j]}); | ~~~~~~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:67, from /usr/include/c++/11/functional:62, from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/11/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from triples.cpp:3: /usr/include/c++/11/bits/stl_vector.h:625:7: note: after user-defined conversion: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 625 | vector(initializer_list<value_type> __l, | ^~~~~~ triples.cpp:9:35: note: initializing argument 1 of 'void is_triple(std::vector<int>&)' 9 | inline void is_triple(vector<int>&g){ | ~~~~~~~~~~~~^ triples.cpp:29:24: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>' 29 | is_triple({i,j,j+v[j]}); | ~~~~~~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:67, from /usr/include/c++/11/functional:62, from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/11/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from triples.cpp:3: /usr/include/c++/11/bits/stl_vector.h:625:7: note: after user-defined conversion: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 625 | vector(initializer_list<value_type> __l, | ^~~~~~ triples.cpp:9:35: note: initializing argument 1 of 'void is_triple(std::vector<int>&)' 9 | inline void is_triple(vector<int>&g){ | ~~~~~~~~~~~~^ triples.cpp:30:24: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>' 30 | is_triple({i,j,i-v[i]}); | ~~~~~~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:67, from /usr/include/c++/11/functional:62, from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/11/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from triples.cpp:3: /usr/include/c++/11/bits/stl_vector.h:625:7: note: after user-defined conversion: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 625 | vector(initializer_list<value_type> __l, | ^~~~~~ triples.cpp:9:35: note: initializing argument 1 of 'void is_triple(std::vector<int>&)' 9 | inline void is_triple(vector<int>&g){ | ~~~~~~~~~~~~^ triples.cpp:31:24: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>' 31 | is_triple({i,j,j-v[i]}); | ~~~~~~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:67, from /usr/include/c++/11/functional:62, from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/11/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from triples.cpp:3: /usr/include/c++/11/bits/stl_vector.h:625:7: note: after user-defined conversion: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 625 | vector(initializer_list<value_type> __l, | ^~~~~~ triples.cpp:9:35: note: initializing argument 1 of 'void is_triple(std::vector<int>&)' 9 | inline void is_triple(vector<int>&g){ | ~~~~~~~~~~~~^ triples.cpp:32:24: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>' 32 | is_triple({i,j,i-v[j]}); | ~~~~~~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:67, from /usr/include/c++/11/functional:62, from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/11/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from triples.cpp:3: /usr/include/c++/11/bits/stl_vector.h:625:7: note: after user-defined conversion: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 625 | vector(initializer_list<value_type> __l, | ^~~~~~ triples.cpp:9:35: note: initializing argument 1 of 'void is_triple(std::vector<int>&)' 9 | inline void is_triple(vector<int>&g){ | ~~~~~~~~~~~~^ triples.cpp:33:24: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>' 33 | is_triple({i,j,j-v[j]}); | ~~~~~~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:67, from /usr/include/c++/11/functional:62, from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/11/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from triples.cpp:3: /usr/include/c++/11/bits/stl_vector.h:625:7: note: after user-defined conversion: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 625 | vector(initializer_list<value_type> __l, | ^~~~~~ triples.cpp:9:35: note: initializing argument 1 of 'void is_triple(std::vector<int>&)' 9 | inline void is_triple(vector<int>&g){ | ~~~~~~~~~~~~^