Submission #1251010

#TimeUsernameProblemLanguageResultExecution timeMemory
1251010somefolkTriple Peaks (IOI25_triples)C++20
Compilation error
0 ms0 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;
}

int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    cout << count_triples(a);

    return 0;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccNDkAUk.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccmiJJk3.o:triples.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status