Submission #1251409

#TimeUsernameProblemLanguageResultExecution timeMemory
1251409tranvinhhuy2010Triple Peaks (IOI25_triples)C++20
0 / 100
100 ms30648 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, set <int>> mk; ll count_triples(vector<int> H) { n = H.size(); ll cnt = 0; set<tuple<int, int, int>> seen; 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 (l + x < n && H[l + x] == y) { int i = l, k = l + x + y; if (k < n && i < j && j < k) seen.emplace(i, j, k); } if (y != x && l + y < n && H[l + y] == y) { int i = l, k = l + y + x; if (k < n && i < j && j < k) seen.emplace(i, j, k); } } } int r = j + H[j]; if (r < n) { int x = H[r]; int y = H[j] - x; if (y > 0) { if (j + x < n && H[j + x] == y) { int i = j - x, k = r; if (i >= 0 && i < j && j < k) seen.emplace(i, j, k); } if (y != x && j + y < n && H[j + y] == y) { int i = j - y, k = r; if (i >= 0 && i < j && j < k) seen.emplace(i, j, k); } } } mk[j - H[j]].insert(j); } for (int i = 0; i < n; i++) { mk[i - H[i]].erase(i); for (int k : mk[i + H[i]]) { if (k <= i) continue; int j1 = i + H[i], j2 = i + H[k]; if (j1 < k && j1 < n && H[j1] == k - i) seen.emplace(i, j1, k); if (j2 < k && j2 < n && H[j2] == k - i) seen.emplace(i, j2, k); } } return seen.size(); } vector<int> construct_range(int M, int K) { return {1, 1, 1}; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...