Submission #1250333

#TimeUsernameProblemLanguageResultExecution timeMemory
1250333guymmk3개의 봉우리 (IOI25_triples)C++20
Compilation error
0 ms0 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
#include "triples.h"
using namespace std;
vector<int> v
int 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 (int)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>a,b;
                vector<int>g={i,j,k};
                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());
                ans+= (int)(a==b);
            }
        }
    }return ans;
}

vector<int> construct_range(int M, int K) {
  return {1, 1, 1};
}

Compilation message (stderr)

triples.cpp:7:1: error: expected initializer before 'int'
    7 | int is_triple(vector<int>g){
      | ^~~
triples.cpp: In function 'long long int count_triples(std::vector<int>)':
triples.cpp:16:5: error: 'v' was not declared in this scope
   16 |     v=hsh;
      |     ^
triples.cpp:25:43: error: no match for 'operator=' (operand types are 'std::vector<int>' and '<brace-enclosed initializer list>')
   25 |                 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:3:
/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:3:
/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)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~