제출 #1017644

#제출 시각아이디문제언어결과실행 시간메모리
1017644serkanrashid곤돌라 (IOI14_gondola)C++14
25 / 100
18 ms5760 KiB
#include "gondola.h"
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e5+5;

int n,a[maxn];

bool check_valid()
{
    unordered_set<int>used;
    int st = -1;

    for(int i = 0; i < n; i++)
    {
        if(used.find(a[i])!=used.end()) return false;
        used.insert(a[i]);
        if(1<=a[i] && a[i] <= n) st = i;
    }
    if(st==-1) return true;

    bool f = true;
    int last = a[st];
    int i = (st+1)%n;

    while(i!=st)
    {
        last++;
        if(last>n) last = 1;
        if(1<=a[i] && a[i]<=n)
        {
            if(last!=a[i]) return false;
        }
        i = (i+1)%n;
    }
    return true;
}

int valid(int N, int inputSeq[])
{
    n = N;
    for(int i = 0; i < n; i++) a[i] = inputSeq[i];
    return check_valid();
}

vector<int> do_replace()
{
    unordered_set<int>used;
    int l = 0;
    for(int i = 0; i < n; i++)
    {
        if(a[i]>l) l = a[i];
        used.insert(a[i]);
    }
    l = l - n;

    vector<int>res;
    for(int j = 1; j <= l+n; j++) if(used.find(j)==used.end()) res.push_back(j);
    return res;
}

int replacement(int N, int gondolaSeq[], int replacementSeq[])
{
    n = N;
    for(int i = 0; i < n; i++) a[i] = gondolaSeq[i];
    vector<int>pom = do_replace();
    for(int i = 0; i < pom.size(); i++) replacementSeq[i] = pom[i];
    return pom.size();
}

int countReplacement(int N, int inputSeq[])
{
    n = N;
    for(int i = 0; i < n; i++) a[i] = inputSeq[i];
    if(!check_valid()) return 0;
    ///OSHTE


}

컴파일 시 표준 에러 (stderr) 메시지

gondola.cpp: In function 'bool check_valid()':
gondola.cpp:23:10: warning: unused variable 'f' [-Wunused-variable]
   23 |     bool f = true;
      |          ^
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:68:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |     for(int i = 0; i < pom.size(); i++) replacementSeq[i] = pom[i];
      |                    ~~^~~~~~~~~~~~
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:80:1: warning: control reaches end of non-void function [-Wreturn-type]
   80 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...