답안 #1042273

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1042273 2024-08-02T19:00:11 Z dpsaveslives 곤돌라 (IOI14_gondola) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int valid(int n, int inputSeq[]){
    int pos = -1; set<int> vals;
    for(int i = 0;i<n;++i){
        if(inputSeq[i] <= n && pos == -1){
            pos = i;
        }
        vals.insert(inputSeq[i]);
    }
    if(vals.size() != n){
        return 0;
    }
    if(pos == -1){
        return 1;
    }
    int cur = inputSeq[pos];
    for(int i = pos;i<n;++i){
        if(inputSeq[i] <= n){
            //cout << i << " " << cur << "\n";
            if(inputSeq[i] != cur){
                return 0;
            }
        }
        if(cur == n){
            cur = 0;
        }
        ++cur;
    }
    for(int i = 0;i<=pos-1;++i){
        if(inputSeq[i] <= n){
            if(inputSeq[i] != cur){
                return 0;
            }
        }
        if(cur == n){
            cur = 0;
        }
        ++cur;

    }
    return 1;
}

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:12:20: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |     if(vals.size() != n){
      |        ~~~~~~~~~~~~^~~~
/usr/bin/ld: /tmp/ccK7weSf.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'
/usr/bin/ld: grader.cpp:(.text.startup+0x132): undefined reference to `replacement'
collect2: error: ld returned 1 exit status