제출 #1249889

#제출 시각아이디문제언어결과실행 시간메모리
1249889kduckp3개의 봉우리 (IOI25_triples)C++20
컴파일 에러
0 ms0 KiB
#include "triples.h" #include <vector> #include <algorithm> #include <unordered_map> using namespace std; bool cmp(pair<int, int> a, pair<int, int> b) { return a.first > b.first; } long long count_triples(vector<int> H) { int n = H.size(); long long res = 0; if (n <= 100) { 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 = {H[i], H[j], H[k]}; vector<int> d = {j - i, k - i, k - j}; sort(h.begin(), h.end()); sort(d.begin(), d.end()); if (h == d) res++; } return res; } bool small_value = true; for (int h : H) if (h > 10) { small_value = false; break; } if (small_value) { for (int i = 0; i < n; ++i) for (int j = i + 1; j < min(n, i + 11); ++j) for (int k = j + 1; k < min(n, i + 22); ++k) { vector<int> h = {H[i], H[j], H[k]}; vector<int> d = {j - i, k - i, k - j}; sort(h.begin(), h.end()); sort(d.begin(), d.end()); if (h == d) res++; } return res; } if (n <= 2000) { unordered_map<int, vector<int>> pos; for (int i = 0; i < n; ++i) pos[H[i]].push_back(i); for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { int d1 = j - i; for (int h3 = 1; h3 <= 2 * d1; ++h3) { vector<int> h = {H[i], H[j], h3}; vector<int> d = {j - i, 0, 0}; if (!pos.count(h3)) continue; const auto& indices = pos[h3]; auto it = upper_bound(indices.begin(), indices.end(), j); for (; it != indices.end(); ++it) { int k = *it; d[1] = k - i; d[2] = k - j; sort(h.begin(), h.end()); sort(d.begin(), d.end()); if (h == d) res++; } } } } return res; } return res; } unordered_map<int, vector<int>> height_positions; for (int i = 0; i < n; i++) { height_positions[H[i]].push_back(i); } for (int i = 0; i < min(n, 1000); ++i) { for (int j = i + 1; j < min(n, i + 1000); ++j) { for (int k = j + 1; k < min(n, i + 2000); ++k) { vector<int> h = {H[i], H[j], H[k]}; vector<int> d = {j - i, k - i, k - j}; sort(h.begin(), h.end()); sort(d.begin(), d.end()); if (h == d) res++; } } } return res; } vector<int> construct_range(int M, int K) { return {1, 1, 2}; }

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

triples.cpp:79:5: error: expected unqualified-id before 'for'
   79 |     for (int i = 0; i < n; i++) {
      |     ^~~
triples.cpp:79:25: error: 'n' was not declared in this scope
   79 |     for (int i = 0; i < n; i++) {
      |                         ^
triples.cpp:79:25: error: 'n' was not declared in this scope
triples.cpp:79:25: error: 'n' was not declared in this scope
triples.cpp:79:25: error: 'n' was not declared in this scope
triples.cpp:79:25: error: 'n' was not declared in this scope
triples.cpp:79:25: error: 'n' was not declared in this scope
triples.cpp:79:25: error: 'n' was not declared in this scope
triples.cpp:79:25: error: 'n' was not declared in this scope
triples.cpp:79:25: error: 'n' was not declared in this scope
triples.cpp:79:21: error: 'i' does not name a type
   79 |     for (int i = 0; i < n; i++) {
      |                     ^
triples.cpp:79:28: error: 'i' does not name a type
   79 |     for (int i = 0; i < n; i++) {
      |                            ^
triples.cpp:83:5: error: expected unqualified-id before 'for'
   83 |     for (int i = 0; i < min(n, 1000); ++i) {
      |     ^~~
triples.cpp:83:29: error: 'n' was not declared in this scope
   83 |     for (int i = 0; i < min(n, 1000); ++i) {
      |                             ^
triples.cpp:83:29: error: 'n' was not declared in this scope
triples.cpp:83:29: error: 'n' was not declared in this scope
triples.cpp:83:29: error: 'n' was not declared in this scope
triples.cpp:83:29: error: 'n' was not declared in this scope
triples.cpp:83:29: error: 'n' was not declared in this scope
triples.cpp:83:29: error: 'n' was not declared in this scope
triples.cpp:83:29: error: 'n' was not declared in this scope
triples.cpp:83:29: error: 'n' was not declared in this scope
triples.cpp:83:21: error: 'i' does not name a type
   83 |     for (int i = 0; i < min(n, 1000); ++i) {
      |                     ^
triples.cpp:83:39: error: expected unqualified-id before '++' token
   83 |     for (int i = 0; i < min(n, 1000); ++i) {
      |                                       ^~
triples.cpp:95:5: error: expected unqualified-id before 'return'
   95 |     return res;
      |     ^~~~~~
triples.cpp:96:1: error: expected declaration before '}' token
   96 | }
      | ^