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;
#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
int valid(int n, int a[])
{
map<int,bool> use;
pair<int,int> mn = {1e9, 1e9};
for(int i = 0; i < n; i++)
{
mn = min(mn, {a[i], i});
if(use.count(a[i])) return 0;
use[a[i]] = true;
}
if(mn.f > n) return 1;
if(mn.f < 1) return 0;
for(int i = 0; i < n; i++)
{
if(a[(mn.s + i) % n] <= n && a[(mn.s + i) % n] != (mn.f + i + n - 1) % n + 1)
return 0;
}
return 1;
}
//----------------------
int to[250005], use[250005];
int replacement(int n, int a[], int ans[])
{
int mx = 0;
int cur = -1, idx = 0;
pair<int,int> mn = {1e9, 1e9};
for(int i = 0; i < n; i++)
mn = min(mn, {a[i], i}), mx = max(mx, a[i]);
for(int i = 0; i < n; i++)
if(a[(mn.s + i) % n] != (mn.f + i + n - 1) % n + 1)
{
to[(mn.f + i + n - 1) % n + 1] = a[(mn.s + i) % n];
if(a[(mn.s + i) % n] == mx)
cur = (mn.f + i + n - 1) % n + 1;
else
use[a[(mn.s + i) % n]] = (mn.f + i + n - 1) % n + 1;
}
for(int i = n + 1; i <= mx; i++)
{
if(use[i])
ans[idx++] = use[i];
else
ans[idx++] = cur, cur = i;
}
return idx;
}
//----------------------
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... |