제출 #1251136

#제출 시각아이디문제언어결과실행 시간메모리
1251136aryan123개의 봉우리 (IOI25_triples)C++20
18 / 100
2095 ms4896 KiB
#include "triples.h" #include <bits/stdc++.h> using namespace std; vector<int> h; vector<bool> vis; bool check_range(int i, int j, int k) { // checks if the range is correct and H[i] is the lowest if(vis[i] || vis[j] || vis[k]) return false; if(i < 0LL || j < 0LL || k < 0LL || k < j) return false; if(i >= h.size() || j >= h.size() || k >= h.size()) return false; vector<long long> diff = {abs(i - j), abs(i - k), abs(j - k)}; vector<long long> diff2 = {h[i], h[j], h[k]}; sort(diff.begin(), diff.end()); sort(diff2.begin(), diff2.end()); return diff == diff2; } long long count_triples(std::vector<int> H) { h = H; long long ans = 0; int n = h.size(); vector<pair<int, int> > h_sizes; vis.resize(n); for(int i = 0; i < n; i++) { h_sizes.push_back({h[i], i}); vis[i] = false; } sort(h_sizes.begin(), h_sizes.end()); for(int i = 0; i < h_sizes.size(); i++) { int idx = h_sizes[i].second; for(int j = 0; j < n; j++) { int this_diff = abs(idx - j); int actual_diff = (h_sizes[i].first == this_diff) ? h[j] : h_sizes[i].first; ans += check_range(idx, j, j - actual_diff); // if(check_range(idx, j, j - actual_diff)) cout << "1: " << idx << " " << j << " " << j - actual_diff << "\n"; ans += check_range(idx, j, j + actual_diff); // if(check_range(idx, j, j + actual_diff)) cout << "2: " << idx << " " << j << " " << j + actual_diff << "\n"; ans += check_range(idx, j, idx - actual_diff); // if(check_range(idx, j, idx - actual_diff)) cout << "3: " << idx << " " << j << " " << i - actual_diff << "\n"; ans += check_range(idx, j, idx + actual_diff); // if(check_range(idx, j, idx + actual_diff)) cout << "4: " << idx << " " << j << " " << i + actual_diff << "\n"; } vis[idx] = true; } return ans; } std::vector<int> construct_range(int M, int K) { // std::mt19937_64 RNG(std::chrono::steady_clock::now().time_since_epoch().count()); // std::vector<int> peak_range; // for(int i = 0; i < M; i++) { // peak_range.push_back(RNG() % 10 + 5); // } // return peak_range; return {}; }
#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...