제출 #1254204

#제출 시각아이디문제언어결과실행 시간메모리
1254204TrendBattles3개의 봉우리 (IOI25_triples)C++17
컴파일 에러
0 ms0 KiB
#include "triples.h"
#include <bits/stdc++.h>
using namespace std;
using lli = int64_t;

lli count_triples(vector <int> H) {
    int N = (int) H.size();

    lli ans = 0;
    for (int iter = 1; iter <= 2; ++iter) {
        for (int i = 0; i < N; ++i) {
            if (i < H[i]) continue;
            int p = i - H[i];

            if (H[p] >= H[i]) continue;

            ans += H[p + H[p]] == H[i] - H[p];

            if (H[i] != H[p] * 2) ans += H[i - H[p]] == H[i] - H[p];
        }

        reverse(H.begin(), H.end());
    }

    for (int i = 0; i < N; ++i) {
        if (i + H[i] >= N) continue;
        
        int j = i + H[i];
        if (H[j] > H[i]) ans += H[j + H[j] - H[i]] == H[j] - H[i];
    }

    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            if (j - i == H[i] + H[j]) {
                ans += H[i + H[j]] == H[i] + H[j];
            }
        }
    }

    for (int i = 0; i < N; ++i) {
        if (H[i] % 2) continue;

        int half_len = H[i] / 2;
        ans -= i >= half_len and H[i - half_len] == half_len and i + half_len < N and H[i + half_len] == half_len;
    }


    return ans;
}

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

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

triples.cpp:6:5: error: ambiguating new declaration of 'lli count_triples(std::vector<int>)'
    6 | lli count_triples(vector <int> H) {
      |     ^~~~~~~~~~~~~
In file included from triples.cpp:1:
triples.h:3:11: note: old declaration 'long long int count_triples(std::vector<int>)'
    3 | long long count_triples(std::vector<int> H);
      |           ^~~~~~~~~~~~~