제출 #1264318

#제출 시각아이디문제언어결과실행 시간메모리
1264318anangoTriple Peaks (IOI25_triples)C++20
4.41 / 100
14 ms1860 KiB
#include "triples.h" #define ll long long using namespace std; long long count_triples(std::vector<int> H) { //firstly, consider index 1 is part of a mythical triple (1 is a label not an index) //there are two possibilities, either that index 1 and 2 are separated by the height of 1 (or index 1 and 3) //or that indices 2 and 3 are separated by the height of 1 //if it's the former case, it's simple because we can just check index 2 positions +- H_1 of position of index 1 //and then check index 3 positions +- H_2 of position of index 1 and then +- H_2 of position of index 2 //so only 2 index 2 and 4 index 3 positions need to be considered //in the case where indices 2 and 3 are separated by the height of 1 //then if indices 1 and 2 are separated by the height of 2 we're essentially back to the first case //the only really hard case is if indices 1 and 2 are separated by the height of 3 //and indices 1 and 3 are separated by the height of 2 //etc //ok note that one of the pairwise distances is the sum of the other two //and thus one of the heights is the sum of the other two //in fact the middle height is the sum of the 2 outer ones //which means this case is impossible in subtask 4 //so we can easily get 35 points with this solution so far //so we want two indices such that the distance from the first to index 1 on the left is equal to the height of the second //and the distance from index 1 on the right to the second is the height of the first //call these indices a,b and the middle index M //b = a+H[M] //so we definitely need: //M-a = H[b] //b-M = H[a] //so summing, b-a = H[b]+H[a] //maybe we first find pairs of indices such that b-a = H[b]+H[a] and then check that their midpoint works //in fact this means that H[a]+a = b-H[b] //so we can look at the values of H[a]+a over all a, look at the values of b-H[b] over all b, and then see for overlaps return 0ll; } std::vector<int> construct_range(int M, int K) { vector<int> pattern = {3,3,2,1,1,3}; int pl = pattern.size(); vector<int> result; for (int i=0; i<M; i++) { result.push_back(pattern[i%pl]); } return result; }
#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...