This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
bool mark[250000 + 10];
int valid(int n, int inputSeq[]){
for (int i = 0; i < n; i++){
if (mark[inputSeq[i]])
return false;
mark[inputSeq[i]] = 1;
}
int idx = min_element(inputSeq, inputSeq+n) - inputSeq;
if (inputSeq[idx] > n)
return true;
int cnt = 0;
for (int i = idx; i < n; i++){
if (inputSeq[i] <= n and inputSeq[idx]+cnt != inputSeq[i])
return false;
cnt ++;
}
for (int i = 0; i < idx; i++){
if (inputSeq[i] <= n and inputSeq[idx]+cnt != inputSeq[i])
return false;
cnt ++;
}
return true;
}
int p[maxn];
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
for (int i = 0; i < n; i++)
p[i] = i+1;
for (int i = 0; i < n; i++){
if (gondolaSeq[i] > n)
continue;
int cnt = 0;
for (int j = i; j < n; j++)
p[j] = (gondolaSeq[i]+cnt-1)%n+1, cnt++;
for (int j = 0; j < i; j++)
p[j] = (gondolaSeq[i]+cnt-1)%n+1, cnt++;
break;
}
vector<pair<int,int>> A;
for (int i = 0; i < n; i++)
A.push_back({gondolaSeq[i],i});
sort(A.begin(),A.end());
int l = 0, now = n+1;
for (auto it : A){
int i = it.second;
if (gondolaSeq[i] <= n)
continue;
while (now <= gondolaSeq[i])
replacementSeq[l++] = p[i], now++;
}
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... |