답안 #763629

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
763629 2023-06-22T14:26:25 Z Ahmed57 곤돌라 (IOI14_gondola) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
int valid(int n, int inputSeq[]);
int replacement(int n, int gondolaSeq[], int replacementSeq[]);
int countReplacement(int n, int inputSeq[]);

int valid(int n, int inputSeq[]){
    bool ss = 0;
    int ind = 0 , val = 0;
    for(int i = 0;i<n;i++){
        if(inputSeq[i]<=n){
            ss = 1;
            val = inputSeq[i]-1;
            ind = i;
        }
    }
    if(!ss)return 1;
    for(int i = ind+1;i<n;i++){
        val++;
        val%=n;
        if(inputSeq[i]<=n){
            if((inputSeq[i]-1)!=val)return 0;
        }
    }
    for(int i = 0;i<ind;i++){
        val++;val%=n;
        if(inputSeq[i]<=n){
            if((inputSeq[i]-1)!=val)return 0;
        }
    }
    return 1;
}int replacement(int n, int gondolaSeq[], int replacementSeq[]){
    vector<pair<int,int>> v;
    int ind = 0, val = 0;bool ss = 0;
    for(int i = 0;i<n;i++){
        if(gondolaSeq[i]<=n){
            ind = i;val = gondolaSeq[i]-1;
            ss = 1;
        }
    }
    int lol[n];
    if(ss){
        lol[ind] = val;
        for(int i = ind+1;i<n;i++){
            val++;
            val%=n;
            lol[i] = val;
        }
        for(int i = 0;i<ind;i++){
            val++;val%=n;
            lol[i] = val;
        }
    }
    for(int i = 0;i<n;i++){
        if(gondolaSeq[i]>n){
            v.push_back({gondolaSeq[i],(ss==0?i+1:lol[i]+1)});
        }
    }
    sort(v.begin(),v.end());
    int l = n+1;
    int st =0;
    for(int i = 0;i<v.size();i++){
        replacementSeq[st++] = v[i].second;
        ++l;
        while(l<=v[i].first){
            replacementSeq[st++] = l-1;
            l++;
        }
    }
    return st;
}
int countReplacement(int n, int inputSeq[]){
    return 0;
}
/*
int main(){
    int S[] = {10, 4, 3, 11, 12};
    cout<<valid(6,S);
}*/

Compilation message

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:63:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for(int i = 0;i<v.size();i++){
      |                   ~^~~~~~~~~
/usr/bin/ld: /tmp/ccfjwjRx.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