제출 #1251123

#제출 시각아이디문제언어결과실행 시간메모리
1251123aryan12Triple Peaks (IOI25_triples)C++20
컴파일 에러
0 ms0 KiB
#include "triples.h"
#include <bits/stdc++.h>

long long count_triples(std::vector<int> H) {
  long long ans = 0;
  int N = H.size();
  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> index_diff = {j - i, k - i, k - j};
        sort(index_diff.begin(), index_diff.end());
        if(index_diff[0] == i && index_diff[1] == j && index_diff[2] == k) {
          ans += 1;
        }
      }
    }
  }
  return ans;
}

std::vector<int> construct_range(int M, int K) {
  // std::mt19937_64 RNG(std::chrono::steady_clock::now().time_since_epoch().count());
  // std::vector<int> peak_range;
  // for(int i = 0; i < M; i++) {
  //   peak_range.push_back(RNG() % 10 + 5);
  // }
  // return peak_range;
  return {};
}

컴파일 시 표준 에러 (stderr) 메시지

triples.cpp: In function 'long long int count_triples(std::vector<int>)':
triples.cpp:10:9: error: 'vector' was not declared in this scope
   10 |         vector<long long> index_diff = {j - i, k - i, k - j};
      |         ^~~~~~
triples.cpp:10:9: note: suggested alternatives:
In file included from /usr/include/c++/11/vector:67,
                 from triples.h:1,
                 from triples.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from triples.h:1,
                 from triples.cpp:1:
/usr/include/c++/11/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
triples.cpp:10:16: error: expected primary-expression before 'long'
   10 |         vector<long long> index_diff = {j - i, k - i, k - j};
      |                ^~~~
triples.cpp:11:14: error: 'index_diff' was not declared in this scope
   11 |         sort(index_diff.begin(), index_diff.end());
      |              ^~~~~~~~~~
triples.cpp:11:9: error: 'sort' was not declared in this scope
   11 |         sort(index_diff.begin(), index_diff.end());
      |         ^~~~
triples.cpp:11:9: note: suggested alternatives:
In file included 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/pstl/glue_algorithm_defs.h:296:1: note:   'std::sort'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
In file included from /usr/include/c++/11/algorithm:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from triples.cpp:2:
/usr/include/c++/11/bits/ranges_algo.h:1834:30: note:   'std::ranges::sort'
 1834 |   inline constexpr __sort_fn sort{};
      |                              ^~~~