제출 #1252431

#제출 시각아이디문제언어결과실행 시간메모리
1252431chr343개의 봉우리 (IOI25_triples)C++20
0 / 100
2096 ms1860 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; // 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; }*/
#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...