Submission #1269043

#TimeUsernameProblemLanguageResultExecution timeMemory
1269043kawhietGondola (IOI14_gondola)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "gondola.h"
using namespace std;

int gondolaSequence[100001];
int replacementSequence[250001];

int valid(int n, int inputSeq[]) {
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = inputSeq[i];
        a[i] %= n;
        if (a[i] == 0) {
            a[i] = n;
        }
    }
    for (int i = 1; i < n; i++) {
        if (a[i] % n != (a[i - 1] + 1) % n) {
            return 0;
        }
    }
    return 1;
}

int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
    vector<pair<int, int>> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        a[i] = {gondolaSeq[i], i};
    }
    vector<int> val(n);
    gondolaSeq[0] %= n;
    if (gondolaSeq[0] == 0) gondolaSeq[0] = n;
    for (int i = 0; i < n; i++) {
        if (gondolaSeq[i] <= n) {
            val[i] = gondolaSeq[i];
            for (int j = i - 1; j >= 0; j--) {
                val[j] = val[j + 1] - 1;
                if (val[j] == 0) {
                    val[j] = n;
                }
            }
            for (int j = i + 1; j < n; j++) {
                val[j] = val[j - 1] + 1;
                if (val[j] == n + 1) {
                    val[j] = 1;
                }
            }
        }
        break;
    }
    sort(a.begin(), a.end());
    int j = 0, res = 0, x = n;
    for (auto [k, i] : a) {
        int y = val[i];
        bool first = 1;
        while (k > x) {
            res++;
            if (first) {
                first = 0;
                replacementSeq[j++] = val[i];
            }
            else {
                replacementSeq[j++] = x;
            }
            x++;
        }
    }
    return res;
}

int countReplacement(int n, int inputSeq[]) {
    return 0;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cc8pqKfU.o:(.bss+0xf4260): multiple definition of `gondolaSequence'; /tmp/ccLEJ5b2.o:(.bss+0xf4260): first defined here
/usr/bin/ld: /tmp/cc8pqKfU.o:(.bss+0x0): multiple definition of `replacementSequence'; /tmp/ccLEJ5b2.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status