Submission #1361490

#TimeUsernameProblemLanguageResultExecution timeMemory
1361490jalol250Triple Peaks (IOI25_triples)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

// ---------------- PART I ----------------
long long count_triples(vector<int> &H){
    int n = H.size();
    long long ans = 0;

    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1; k < n; k++){
                int a = H[i], b = H[j], c = H[k];
                int x = j - i, y = k - j, z = k - i;

                if( (a==x && b==y && c==z) ||
                    (a==x && b==z && c==y) ||
                    (a==y && b==x && c==z) ||
                    (a==y && b==z && c==x) ||
                    (a==z && b==x && c==y) ||
                    (a==z && b==y && c==x) ){
                    ans++;
                }
            }
        }
    }
    return ans;
}

// ---------------- PART II ----------------
vector<int> construct_range(int M, int K){
    int n = M;
    if(n > 1000) n = 1000;
    if(n < 3) n = 3;

    vector<int> H(n);
    for(int i = 0; i < n; i++){
        H[i] = i + 1;
    }

    return H;
}

// ---------------- MAIN ----------------
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int type;
    cin >> type;

    if(type == 1){
        // Part I
        int n;
        cin >> n;
        vector<int> H(n);
        for(int i = 0; i < n; i++) cin >> H[i];

        cout << count_triples(H);
    }
    else{
        // Part II
        int M, K;
        cin >> M >> K;

        vector<int> H = construct_range(M, K);

        cout << H.size() << '\n';
        for(int x : H) cout << x << ' ';
    }
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccV63n8z.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc4Bvys2.o:triples.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccV63n8z.o: in function `main':
grader.cpp:(.text.startup+0x367): undefined reference to `count_triples(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status