Submission #1252674

#TimeUsernameProblemLanguageResultExecution timeMemory
1252674lrnnzTriple Peaks (IOI25_triples)C++20
0 / 100
46 ms4420 KiB
#include <bits/stdc++.h> #include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <iomanip> #include <queue> #include <random> #include "triples.h" using namespace std; #define all(a) (a).begin(), (a).end() #define ll long long #define ld long double #define ui uint64_t #define cont(set, element) ((set).find(element) != (set).end()) #define pb push_back #define chmin(x, y) (x = min(x, y)) #define chmax(x, y) (x = max(x, y)) /********* DEBUG *********/ template <typename T> void outvec(const vector<T>& Z){ for (const T& x : Z) cout << x << ' '; cout << "\n"; } void printVariable(const any& var) { if (!var.has_value()) { cout << "null"; return; } if (var.type() == typeid(int)) { cout << any_cast<int>(var); } else if (var.type() == typeid(double)) { cout << any_cast<double>(var); } else if (var.type() == typeid(float)) { cout << any_cast<float>(var); } else if (var.type() == typeid(char)) { cout << any_cast<char>(var); } else if (var.type() == typeid(bool)) { cout << (any_cast<bool>(var) ? "true" : "false"); } else if (var.type() == typeid(string)) { cout << any_cast<string>(var); } else if (var.type() == typeid(const char*)) { cout << any_cast<const char*>(var); } else if (var.type() == typeid(long long)) { cout << any_cast<long long>(var); } else { cout << "[unknown type]"; } } template<typename... Args> void outval(Args... args) { vector<any> variables = {args...}; for (size_t i = 0; i < variables.size(); ++i) { printVariable(variables[i]); if (i != variables.size() - 1) { cout << " "; } } cout << "\n"; } /********* DEBUG *********/ #define sp << " " << #define fi first #define se second const ll MOD2 = 1e9 + 7; const ll MOD = 998244353; const ll inf = 1e18; ll brute(vector<int> H){ ll ans = 0; for (int i = 2; i < H.size(); i++){ for (int j = i-1; j; j--){ for (int k = j-1; k >= 0; k--){ vector<ll> dist = {i-j, j-k, i-k}; if (dist[1] < dist[0]) swap(dist[1], dist[0]); vector<ll> vals = {H[i], H[j], H[k]}; sort(all(vals)); if (dist[0] == vals[0] && dist[1] == vals[1] && dist[2] == vals[2]){ ans++; outval("i,j,k:",i,j,k); } } } } return ans; } ll count_triples(vector<int> H) { ll ans = 0; for (int i = 2; i < H.size(); i++){ if (i < H[i]) continue; ll back = i - H[i]; ll sum1 = H[back]; if (back + sum1 < H.size()){ sum1 += H[back + sum1]; sum1 += back; if (sum1 == i){ ans++; } } ll front = i-H[back]; if (back + H[back] != front && front - H[front] == back){ outval("yeah_",i); ans++; } //outval("i, ans:",i,ans); } return ans; } std::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...