Submission #1249547

#TimeUsernameProblemLanguageResultExecution timeMemory
1249547Charizard2021Triple Peaks (IOI25_triples)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include "triples.h"
using namespace std;
long long count_triples(vector<int> H){
    long long n = (long long)H.size();
    if(n <= 100){
        long long ans = 0;
        for(long long i = 0; i < n; i++){
            for(long long j = i + 1; j < n; j++){
                for(long long k = j + 1; k < n; k++){
                    vector<long long> v;
                    v.push_back(j - i);
                    v.push_back(k - j);
                    v.push_back(k - i);
                    vector<long long> v2;
                    v2.push_back(H[i]);
                    v2.push_back(H[j]);
                    v2.push_back(H[k]);
                    sort(v2.begin(), v2.end());
                    sort(v.begin(), v.end());
                    if(v == v2){
                        ans++;
                    }
                }
            }
        }
        return ans;
    }
    long long thing = 0;
    for(long long i = 0; i < n; i++){
        thing = max(thing, H[i]);
    }
    if(thing <= 10){
        long long ans = 0;
        for(long long i = 0; i + 10 < n; i++){
            for(long long j = i + 1; j <= i + 10; j++){
                for(long long k = j + 1; k <= i + 10; k++){
                    vector<long long> v;
                    v.push_back(j - i);
                    v.push_back(k - j);
                    v.push_back(k - i);
                    vector<long long> v2;
                    v2.push_back(H[i]);
                    v2.push_back(H[j]);
                    v2.push_back(H[k]);
                    sort(v2.begin(), v2.end());
                    sort(v.begin(), v.end());
                    if(v == v2){
                        ans++;
                    }
                }
            }
        }
        return ans;
    }
}

std::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:31:20: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   31 |         thing = max(thing, H[i]);
      |                 ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from triples.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
triples.cpp:31:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   31 |         thing = max(thing, H[i]);
      |                 ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from triples.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
triples.cpp:31:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   31 |         thing = max(thing, H[i]);
      |                 ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from triples.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
triples.cpp:31:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |         thing = max(thing, H[i]);
      |                 ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from triples.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
triples.cpp:31:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |         thing = max(thing, H[i]);
      |                 ~~~^~~~~~~~~~~~~
triples.cpp:56:1: warning: control reaches end of non-void function [-Wreturn-type]
   56 | }
      | ^