이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
//#include "grader.cpp"
#include <set>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN = 1e5 + 5;
namespace Valid
{
bool seen[MAXN];
bool sortedL[MAXN], sortedR[MAXN];
bool check(int n, int a[], int relevant)
{
int maxVal = 0;
for(int i = 0;i<n;i++)
{
maxVal = max(maxVal, a[i]);
sortedL[i] = sortedR[i] = false;
}
for(int i = 0;i<=maxVal;i++)
{
seen[i] = false;
}
for(int i = 0;i<n;i++)
{
if(seen[ a[i] ]==true) return false;
seen[ a[i] ] = true;
}
sortedL[0] = true;
for(int i = 1;i<n;i++)
{
if(a[i]>relevant) sortedL[i] = sortedL[i-1];
else sortedL[i] = (sortedL[i-1]&(a[i-1]<a[i]));
}
sortedR[n-1] = true;
for(int i = n-2;i>=0;i--)
{
if(a[i]>relevant) sortedR[i] = sortedR[i+1];
else sortedR[i] = (sortedR[i+1]&(a[i]<a[i+1]));
}
if(sortedL[n-1]==true) return true;
for(int i = 0;i<n-1;i++)
{
if(sortedL[i]==true && sortedR[i+1]==true)
{
if((a[i]>relevant && seen[n]==false)
|| (a[i+1]>relevant && seen[1]==false)
|| (a[i]==n && a[i+1]==1))
{
return true;
}
}
}
return false;
}
};
int valid(int n, int inputSeq[])
{
return Valid::check(n, inputSeq, n);
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
return -2;
}
//----------------------
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... |