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;
int valid(int n, int a[])
{
int sm = INT_MAX, pos = -1;
map<int,int> M; M.clear();
for(int i = 0; i < n; i++)
{
M[a[i]]++;
if(M[a[i]]>=2)return 0;
}
for(int i = 0; i < n; i++)
if(sm>a[i] and a[i]<=n)sm=a[i], pos=i;
if(sm==INT_MAX)return 1;
int x = n;
while(x--){
if(a[pos]==n and a[(pos+1)%n]<=n and a[(pos+1)%n]!=1)return 0;
else if(a[pos]<n and a[(pos+1)%n]<=n and a[pos]!=a[(pos+1)%n]-1) return 0;
pos++, pos%=n;
}
return 1;
}
int replacement(int n, int a[], int b[])
{
map<int,int> M; M.clear();
set<int> S; S.clear();
vector<int> v; v.clear();
int x = n, pos = 0, mx = 0;
for(int i = 0; i < n; i++) S.insert(a[i]), mx = max(mx, a[i]);
for(int i = 0; i < n; i++)
if(a[i]<=n) pos = (i-a[i]+n+1)%n;
int z = 1; while(x--) M[a[pos]]=z, z++, pos++, pos%=n;
for(int i = n+1; i <= mx; i++){
if(S.count(i)) v.push_back(M[i]), M[i]=i;
else{
int x = *S.lower_bound(i);
v.push_back(M[x]), M[x]=i;
}
}
for(int i = 0; i < (int)v.size(); i++) b[i]=v[i];
return (int)v.size();
}
int countReplacement(int n, int a[])
{
return 1;
}
# | 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... |