Submission #1253204

#TimeUsernameProblemLanguageResultExecution timeMemory
1253204JasonweiTriple Peaks (IOI25_triples)C++20
75.08 / 100
195 ms24688 KiB
/* -A2 --indent=tab=4 --indent-classes --indent-switches --indent-namespaces --indent-preprocessor -xg -p -xd -H -xj -xe read all problems do first-eye problems read rev order uhhh dont fail impl */ #include <bits/stdc++.h> #define ll long long #define double long double #define re(a, b, c, d) for (auto a = b; a <= c; a += d) #define de(a, b, c, d) for (auto a = b; a >= c; a -= d) #define ms(a, b) memset(a, b, sizeof (a)) #define imax INT_MAX #define imin INT_MIN #define wh(a) while (a --) #define PII pair <int, int> #define F first #define S second #define pb push_back #define eb emplace_back template <typename T> bool chkmin (T &a, T b) { return (b < a) ? a = b, 1 : 0; } template <typename T> bool chkmax (T &a, T b) { return (b > a) ? a = b, 1 : 0; } using namespace std; const int N = 2e5 + 5; int n; unordered_map <int, vector <int> > m; ll count_triples (vector <int> H) { n = H.size(); ll cnt = 0; re (j, 0, n - 1, 1) { 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++; } } } re (k, 0, n - 1, 1) { 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]].pb (k); } return cnt; } vector<int> construct_range (int M, int K) { return {2, 1, 2, 1, 4, 3, 6, 5, 8, 7, 2, 9, 4, 5, 2, 3, 4, 1, 2, 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...