제출 #1252424

#제출 시각아이디문제언어결과실행 시간메모리
1252424chr343개의 봉우리 (IOI25_triples)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; //#define int long long #define endl "\n" #define dbg(x) cout << #x << " = " << (x) << endl; const long long INF = 1e18; const int MAXN = 1e6 + 10; const int MOD = 1e9 + 7; bool match(vector<int> a, vector<int> b){ sort(a.begin(), a.end()); sort(b.begin(), b.end()); for(int i = 0; i < 3; ++i) if(a[i] != b[i]) return false; return true; } long long count_triples(vector<int> h) { int n = h.size(); long long ans = 0; for(int i = 0; i < n; ++i) { for(int j = i+1; j < n; ++j) { int hi = h[i]; int hj = h[j]; int di = j - i // solve for k, and check // 1) hi=di, hj=dj, hk=dk if (hi == di) { int dj = hj; // so dj = H[j] int k = j + dj; // k = j + (k-j) if (k < N && k > j && H[k] == di + dj) ans++; } // 2) hi=di, hj=dk, hk=dj if (hi == di) { // hj = dk = di + dj => dj = hj - di int dj = hj - di; int k = j + dj; if (dj > 0 && k < N && k > j && H[k] == dj) ans++; } // 3) hi=dj, hj=di, hk=dk if (hj == di) { int dj = hi; int k = j + dj; if (k < N && k > j && H[k] == di + dj) ans++; } // 4) hi=dj, hj=dk, hk=di // hi = dj // hj = dk = di + dj if (hj == di + hi) { int dj = hi; int k = j + dj; if (k < N && k > j && H[k] == di) ans++; } // 5) hi=dk, hj=di, hk=dj // hi = dk = di + dj => dj = hi - di if (hj == di) { int dj = hi - di; int k = j + dj; if (dj > 0 && k < N && k > j && H[k] == dj) ans++; } // 6) hi=dk, hj=dj, hk=di // hi = di + dj => dj = hi - di // hj = dj => hj == hi - di if (hj == hi - di) { int dj = hi - di; int k = j + dj; if (dj > 0 && k < N && k > j && H[k] == di) ans++; } } } return ans; } vector<int> construct_range(int m, int k){ return {}; } /*int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); //freopen("input.in", "r", stdin); //freopen("input.out", "w", stdout); cout<<count_triples({4, 1, 4, 3, 2, 6, 1}); return 0; }*/

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

triples.cpp: In function 'long long int count_triples(std::vector<int>)':
triples.cpp:33:13: error: expected ',' or ';' before 'if'
   33 |             if (hi == di) {
      |             ^~
triples.cpp:45:35: error: 'N' was not declared in this scope
   45 |                 if (dj > 0 && k < N && k > j && H[k] == dj)
      |                                   ^
triples.cpp:45:49: error: 'H' was not declared in this scope
   45 |                 if (dj > 0 && k < N && k > j && H[k] == dj)
      |                                                 ^
triples.cpp:53:25: error: 'N' was not declared in this scope
   53 |                 if (k < N && k > j && H[k] == di + dj)
      |                         ^
triples.cpp:53:39: error: 'H' was not declared in this scope
   53 |                 if (k < N && k > j && H[k] == di + dj)
      |                                       ^
triples.cpp:63:25: error: 'N' was not declared in this scope
   63 |                 if (k < N && k > j && H[k] == di)
      |                         ^
triples.cpp:63:39: error: 'H' was not declared in this scope
   63 |                 if (k < N && k > j && H[k] == di)
      |                                       ^
triples.cpp:72:35: error: 'N' was not declared in this scope
   72 |                 if (dj > 0 && k < N && k > j && H[k] == dj)
      |                                   ^
triples.cpp:72:49: error: 'H' was not declared in this scope
   72 |                 if (dj > 0 && k < N && k > j && H[k] == dj)
      |                                                 ^
triples.cpp:82:35: error: 'N' was not declared in this scope
   82 |                 if (dj > 0 && k < N && k > j && H[k] == di)
      |                                   ^
triples.cpp:82:49: error: 'H' was not declared in this scope
   82 |                 if (dj > 0 && k < N && k > j && H[k] == di)
      |                                                 ^