Submission #1251011

#TimeUsernameProblemLanguageResultExecution timeMemory
1251011somefolkTriple Peaks (IOI25_triples)C++20
0 / 100
14 ms1860 KiB
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <complex>
#include <list>
#include <cassert>
#include <chrono>
#include <random>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;

#define endl "\n"
#define ll long long

const int INF = 1e9+7;
const int MOD = 1e9+7;

vector<int> construct_range(int m, int k){
    return {};
}

bool check(int d1, int d2, int d3, int h1, int h2, int h3){
    return (((d1 == h1 && d2 == h2 && d3 == h3) ||
        (d1 == h1 && d2 == h3 && d3 == h2) ||
        (d1 == h2 && d2 == h1 && d3 == h3) ||
        (d1 == h2 && d2 == h3 && d3 == h1) ||
        (d1 == h3 && d2 == h1 && d3 == h2) ||
        (d1 == h3 && d2 == h2 && d3 == h1)));
}

ll count_triples(vector<int> a){
    int n = (int)a.size();

    ll cnt = 0;

    // if(n <= 100){
    //     for(int i = 0; i < n; i++){
    //         for(int j = i; j < n; j++){
    //             for(int k = j; k < n; k++){
    //                 cnt += check(j-i, k-j, k-i, a[i], a[j], a[k]);
    //             }
    //         }
    //     }
    //     return cnt;
    // }

    auto forward = [&](int i){
        int first = a[i];
        if(i+first>=n) return;
        int second = a[i+first];
        if(i+first+second>=n) return;
        int third = a[i+first+second];
        if(third == first+second){
            cnt++;
        }
    };

    auto backfor = [&](int i){
        int first = a[i];
        if(i-first<0) return;
        int second = a[i-first];
        if(i+second>=n) return;
        int third = a[i+second];
        if(first <= second && second <= third) return;
        if(first >= second && second >= third) return;
        if(third == first+second){
            cnt++;
        }
    };

    auto backward = [&](int i){
        int first = a[i];
        if(i-first<0) return;
        int second = a[i-first];
        if(i-first-second<0) return;
        int third = a[i-first-second];
        if(first == third+second){
            cnt++;
        }
    };

    for(int i = 0; i < n; i++){
        forward(i);
        backfor(i);
        backward(i);
    }

    return cnt;
}
#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...