제출 #1307045

#제출 시각아이디문제언어결과실행 시간메모리
1307045MunkhErdene3개의 봉우리 (IOI25_triples)C++17
16.29 / 100
63 ms37120 KiB
#include "triples.h" #include <bits/stdc++.h> using namespace std; #define _ << ' ' << using ll = long long; long long count_triples(std::vector<int> H) { vector<ll> a(H.begin(), H.end()); ll n = a.size(); vector<array<ll, 3>> cand; cand.reserve(n * 6); for(ll i = 0; i < n; i++) { for(ll d = 0; d < 1; d++) { ll j = i + a[i]; if(j >= n) continue; ll k = j + a[j]; if(k >= n) continue; array<ll, 3> temp = {i, j, k}; if(i < j && j < k) cand.push_back(temp); } for(ll d = 0; d < 1; d++) { ll j = i + a[i]; if(j >= n) continue; ll k = i + a[j]; if(k >= n) continue; array<ll, 3> temp = {i, j, k}; if(i < j && j < k) cand.push_back(temp); } for(ll d = 0; d < 1; d++) { ll k = i + a[i]; if(k >= n) continue; ll j = k - a[k]; if(j >= n || j <= i) continue; array<ll, 3> temp = {i, j, k}; if(i < j && j < k) cand.push_back(temp); } } for(ll j = 0; j < n; j++) { for(ll d = 0; d < 1; d++) { ll i = j - a[j]; if(i < 0) continue; ll k = j + a[i]; if(k >= n) continue; array<ll, 3> temp = {i, j, k}; if(i < j && j < k) cand.push_back(temp); } for(ll d = 0; d < 1; d++) { ll k = j + a[j]; if(k >= n) continue; ll i = j - a[k]; if(i < 0) continue; array<ll, 3> temp = {i, j, k}; if(i < j && j < k) cand.push_back(temp); } } for(ll k = 0; k < n; k++) { ll j = k - a[k]; if(j < 0) continue; ll i = k - a[j]; if(i < 0) continue; array<ll, 3> temp = {i, j, k}; if(i < j && j < k) cand.push_back(temp); } sort(cand.begin(), cand.end()); cand.erase(unique(cand.begin(), cand.end()), cand.end()); ll ans = 0; for(auto &[i, j, k] : cand) { array<ll, 3> temp1 = {j - i, k - j, k - i}; array<ll, 3> temp2 = {a[i], a[j], a[k]}; sort(temp1.begin(), temp1.end()); sort(temp2.begin(), temp2.end()); if(temp1 == temp2) ans++; } return ans; } std::vector<int> construct_range(int M, int K) { vector<int> res(M); iota(res.begin(), res.end(), 0); res[0] = 1; return res; }
#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...