이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
set<int> existe;
int valid(int n, int inputSeq[])
{
int valido = 1, inicio = -1, valor = INT_MAX;
for(int i = 0; i < n; ++i){
if(inputSeq[i] <= n && inputSeq[i] < valor){
inicio = i;
valor = inputSeq[i];
}
if(existe.count(inputSeq[i]) != 0){
valido = 0;
}
existe.insert(inputSeq[i]);
}
if(inicio != -1){
valor++;
for(int i = inicio + 1; i < n; ++i){
if(inputSeq[i] <= n && inputSeq[i] != valor){
valido = 0;
}
valor++;
}
for(int i = 0; i < inicio; ++i){
if(inputSeq[i] <= n && inputSeq[i] != valor){
valido = 0;
}
valor++;
}
}
return valido;
}
//----------------------
struct dato{
int original, valor;
};
dato arre[100002];
bool compara(dato a, dato b){
if(a.valor < b.valor){
return true;
}
return false;
}
set<int> ocupe;
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int ind = 0, cont = 0, ini = -1, mayor = INT_MAX;
for(int i = 0; i < n; ++i){
if(gondolaSeq[i] <= n && gondolaSeq[i] < mayor){
mayor = gondolaSeq[i];
ini = i;
}
ocupe.insert(gondolaSeq[i]);
}
if(ini != -1){
for(int i = ini; i < n; ++i){
arre[i].original = mayor;
ocupe.insert(mayor);
arre[i].valor = gondolaSeq[i];
mayor++;
}
for(int i = 0; i < ini; ++i){
arre[i].original = mayor;
ocupe.insert(mayor);
arre[i].valor = gondolaSeq[i];
mayor++;
}
mayor = gondolaSeq[ini] - 1;
for(int i = ini - 1; i >= 0; --i){
if(mayor > 0){
arre[i].original = mayor;
ocupe.insert(mayor);
}
mayor--;
}
}else{
mayor = 1;
for(int i = 0; i < n; ++i){
arre[i].original = mayor;
ocupe.insert(mayor);
arre[i].valor = gondolaSeq[i];
mayor++;
}
}
sort(arre, arre + n, compara);
for(int i = 0; i < n; ++i){
while(arre[i].original < arre[i].valor){
replacementSeq[ind] = arre[i].original;
ind++;
cont++;
while(arre[i].original < arre[i].valor && ocupe.count(arre[i].original) == 1){
arre[i].original++;
}
}
}
return cont;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |