답안 #1017347

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1017347 2024-07-09T07:31:36 Z n3rm1n 곤돌라 (IOI14_gondola) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "gondola.h"
#define endl '\n'
using namespace std;
const int MAXN = 3e5 + 10;
int seen[MAXN];
int valid(int n, int inputSeq[])
{
    int cnt = 0;
    int minim = 1e9;
    int minn = 1e9, maxx = 0;
    for (int i = 0; i < n; ++ i)
    {
        if(seen[inputSeq[i]])return 0;
        if(inputSeq[i] <= n)cnt ++;
        else
        {
            minn = min(minn, inputSeq[i]);
            maxx = max(maxx, inputSeq[i]);
        }
        minim = min(minim, inputSeq[i]);
        seen[inputSeq[i]] = 1;
    }
    int left = n - cnt;
    //cout << left << " " << minn << " " << maxx << endl;
    if(left != 0 && !(minn == n+1 && maxx == minn + left - 1))
        return 0;

    //cout << "here " << endl;
    int seenit = 0, expected = minim;
    int onpoint = n+1;
    for (int i = 0; i < n; ++ i)
    {
        if(inputSeq[i] == minim)
            seenit = 1;
        if(!seenit)continue;
        if(inputSeq[i] > n)
        {
            expected ++;
        }
        else if(inputSeq[i] != expected)
        {
            return 0;
        }
        else expected ++;
    }
    for (int i = 0; i < n; ++ i)
    {
        if(inputSeq[i] == minim)
            break;

        if(inputSeq[i] > n)
        {
            expected ++;
        }
        else if(inputSeq[i] != expected)
        {
            return 0;
        }
        else expected ++;
    }
   return 1;
}

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:31:9: warning: unused variable 'onpoint' [-Wunused-variable]
   31 |     int onpoint = n+1;
      |         ^~~~~~~
/usr/bin/ld: /tmp/ccbJ8BXF.o: in function `main':
grader.cpp:(.text.startup+0x108): undefined reference to `countReplacement'
/usr/bin/ld: grader.cpp:(.text.startup+0x132): undefined reference to `replacement'
collect2: error: ld returned 1 exit status