# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1250319 | guymmk | 3개의 봉우리 (IOI25_triples) | C++20 | 컴파일 에러 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "triples.h"
using namespace std;
vector<int> v
bool is_triple(vector<int>g){
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());
return a==b;
}
long long count_triples(vector<int> hsh) {
v=hsh;
int ans=0;
int n=v.size();
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
for(int k=j+1;k<n;k++){vector<int>h={i,j,k};
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)ans++;
}
}
}return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
triples.cpp:6:1: error: expected initializer before 'bool' 6 | bool is_triple(vector<int>g){ | ^~~~ triples.cpp: In function 'long long int count_triples(std::vector<int>)': triples.cpp:15:5: error: 'v' was not declared in this scope 15 | v=hsh; | ^ triples.cpp:22:20: error: 'g' was not declared in this scope 22 | a={g[1]-g[0],g[2]-g[0],g[2]-g[1]}; | ^ triples.cpp:22:49: error: no match for 'operator=' (operand types are 'std::vector<int>' and '<brace-enclosed initializer list>') 22 | a={g[1]-g[0],g[2]-g[0],g[2]-g[1]}; | ^ In file included from /usr/include/c++/11/vector:72, 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:2: /usr/include/c++/11/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' 198 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/11/bits/vector.tcc:199:42: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<int>&' 199 | operator=(const vector<_Tp, _Alloc>& __x) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ 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:2: /usr/include/c++/11/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:709:26: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>&&' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ~~~~~~~~~^~~ /usr/include/c++/11/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]' 730 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:730:46: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<int>' 730 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ triples.cpp:23:43: error: no match for 'operator=' (operand types are 'std::vector<int>' and '<brace-enclosed initializer list>') 23 | b={v[g[0]],v[g[1]],v[g[2]]}; | ^ In file included from /usr/include/c++/11/vector:72, 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:2: /usr/include/c++/11/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' 198 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/11/bits/vector.tcc:199:42: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<int>&' 199 | operator=(const vector<_Tp, _Alloc>& __x) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ 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:2: /usr/include/c++/11/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:709:26: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>&&' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ~~~~~~~~~^~~ /usr/include/c++/11/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]' 730 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:730:46: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<int>' 730 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~