Submission #1251844

#TimeUsernameProblemLanguageResultExecution timeMemory
1251844tranvinhhuy2010Triple Peaks (IOI25_triples)C++20
Compilation error
0 ms0 KiB
//#include "triples.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int nmax = 2e5 + 5; int n; unordered_map <int, vector <int>> m; ll count_triples(vector <int> H) { n = H.size(); ll cnt = 0; for (int j=0; j<n; j++) { int l = j - H[j]; if(l >= 0) { int x = H[l]; int y = H[j] - x; if(y > 0) { if(H[l + x] == y) cnt++; if(y != x && H[l + y] == y) cnt++; } } int r = j + H[j]; if(r < n) { int x = H[r]; int y = H[j] - x; if(y > 0) { if(H[j + x] == y) cnt++; if(y != x && H[j + y] == y) cnt++; } } } for (int k=0; k<n; k++) { for (int i : m[k - H[k]) { int j1 = i+H[i]; int j2 = i+H[k]; if (j1<k && H[j1]==k-i) cnt++; if (j2<k && j2!=j1 && H[j2]==k-i) cnt++; } m[k + H[k]].push_back(k); } return cnt; } vector<int> construct_range(int M, int K) { return {1, 1, 1}; }

Compilation message (stderr)

triples.cpp: In function 'll count_triples(std::vector<int>)':
triples.cpp:41:32: error: expected ']' before ')' token
   41 |         for (int i : m[k - H[k]) {
      |                                ^
      |                                ]