이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <cstdio>
#include <cassert>
#include <map>
#include <algorithm>
int valid(int n, int inputSeq[])
{
std::map<int, int> map;
for(int i=0;i<n;++i)
{
int x=inputSeq[i]-1;
if(map.find(x) != map.end()) return 0;
map.insert({x, i});
}
for(int i=0;i<n;++i)
if(map.find(i)!=map.end() && map.find((i+1)%n)!=map.end())
{
int u=map[i], v=map[(i+1)%n];
if(v != (u+1)%n)
return 0;
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
for(int i=0;i<n;++i)
if(gondolaSeq[i] <= n && gondolaSeq[i] != i+1)
{
std::rotate(gondolaSeq, gondolaSeq+(i-gondolaSeq[i]+1+n)%n, gondolaSeq+n);
}
std::map<int, int> map;
for(int i=0;i<n;++i)
{
int x=gondolaSeq[i];
assert(map.find(x) == map.end());
map.insert({x, i});
}
int l=0, v=n;
for(auto x:map)
for(int t=x.second+1;v<x.first;)
replacementSeq[l++]=t, t=++v;
return l;
}
//----------------------
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... |