Submission #1019811

# Submission time Handle Problem Language Result Execution time Memory
1019811 2024-07-11T09:13:03 Z NValchanov Gondola (IOI14_gondola) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "gondola.h"

#define endl '\n'

using namespace std;

typedef long long ll;

int replacement(int n, int a[], int ans[])
{
    int min_idx = 0;
    int maxel = 0;

    for(int i = 0; i < n; i++)
    {
        if(a[i] < a[min_idx])
            min_idx = i;
        
        maxel = max(maxel, a[i]);
    }

    vector < int > order;

    for(int i = min_idx; i < n; i++)
    {
        order.push_back(a[i]);
    }
    for(int i = 0; i < min_idx; i++)
    {
        order.push_back(a[i]);
    }

    vector < pair < int, int > > broken;

    for(int i = 0; i < n; i++)
    {
        if(order[i] > n)
            broken.push_back({order[i], i});
    }

    sort(broken.begin(), broken.end());

    if(order.front() > n)
        order.front() = 1;

    for(int i = 1; i < n; i++)
    {
        if(order[i - 1] == n)
        {
            order[i] = 1;
        }
        else
        {
            order[i] = order[i - 1] + 1;
        }
    }

    int last = n;
    int pos = 0;

    for(pair < int, int > p : broken)
    {
        int val = p.first;
        int idx = p.second;

        while(last < val)
        {
            ans[pos++] = order[idx];
            order[idx] = ++last;
        }
    }

    return maxel - n;
}

Compilation message

/usr/bin/ld: /tmp/cc2MYhVz.o: in function `main':
grader.cpp:(.text.startup+0xb6): undefined reference to `valid'
/usr/bin/ld: grader.cpp:(.text.startup+0x108): undefined reference to `countReplacement'
collect2: error: ld returned 1 exit status