답안 #780882

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
780882 2023-07-12T14:14:57 Z vjudge1 곤돌라 (IOI14_gondola) C++17
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include "gondola.h"
#define MAX 250000
using namespace std;
int mark[MAX + 10];
vector <pair <int, int>> v;
int valid(int n, int inputSeq[])
{
    int posOrig = -1;
    for (int i = 0; i < n; i++)
    {
        if (mark[inputSeq[i]] == 1)
            return 0;
        if (inputSeq[i] <= n)
            posOrig = i;
        mark[inputSeq[i]] = 1;
    }
    if (posOrig == -1)
        return 1;
    int pos = posOrig;
    for (int i = 1; i <= n; i++)
    {
        if (inputSeq[pos] <= n && (inputSeq[pos] - inputSeq[posOrig] + n) % n != (pos - posOrig + n) % n)
            return 0;
        pos = (pos + 1) % n;
    }
    return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
    int posOrig = -1;
    for (int i = 0; i < n; i++)
        if (gondolaSeq[i] <= n)
            posOrig = i;
    if (posOrig == -1)
        for (int i = 0; i < n; i++)
            v.push_back({gondolaSeq[i], i + 1});
    else
    {
        int pos = posOrig;
        int ind = gondolaSeq[posOrig];
        for (int i = 1; i <= n; i++)
        {
            if (gondolaSeq[pos] > n)
                v.push_back({gondolaSeq[pos], ind});
            pos = (pos + 1) % n;
            if (ind == n - 1)
                ind = (ind + 1) % n + n;
            else
                ind = (ind + 1) % n;
        }
    }
    sort(v.begin(), v.end());
    int l = 0, nn = n + 1;
    for (auto it : v)
    {
        replacementSeq[l] = it.second;
        l++;
        nn++;
        while (nn <= it.first)
        {
            replacementSeq[l] = nn - 1;
            l++;
            nn++;
        }
    }
    return l;
}

Compilation message

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