Submission #1287035

#TimeUsernameProblemLanguageResultExecution timeMemory
1287035ecen30Triple Peaks (IOI25_triples)C++20
Compilation error
0 ms0 KiB
//This is ChatGPT code. I am using this website to test different AI's and their abilities to solve IOI problems. Please understand. I do not mean to cheat. Just trying to get a good grade on my science project.
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>

long long count_triples(std::vector<int>& H) {
    int N = H.size();
    long long mythical_triples = 0;
    
    // Iterate over all triplets (i, j, k)
    for (int i = 0; i < N - 2; ++i) {
        for (int j = i + 1; j < N - 1; ++j) {
            for (int k = j + 1; k < N; ++k) {
                // Calculate pairwise distances
                std::vector<int> distances = { j - i, k - i, k - j };
                std::vector<int> heights = { H[i], H[j], H[k] };
                
                // Sort both distances and heights
                std::sort(distances.begin(), distances.end());
                std::sort(heights.begin(), heights.end());
                
                // If they match, it's a mythical triple
                if (distances == heights) {
                    mythical_triples++;
                }
            }
        }
    }
    
    return mythical_triples;
}

int main() {
    std::vector<int> H = {4, 1, 4, 3, 2, 6, 1};
    std::cout << "Mythical Triples: " << count_triples(H) << std::endl;
    return 0;
}

Compilation message (stderr)

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