# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
516065 | antonioqbab | Gondola (IOI14_gondola) | C++14 | 37 ms | 4576 KiB |
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 <bits/stdc++.h>
#include <gondola.h>
using namespace std;
int valid(int n, int a[])
{
map<int,int> mp;
int index=-1;
for(int i=0; i<n; ++i)
{
if(mp.count(a[i]))
return 0;
++mp[a[i]];
}
for(int i=0; i<n; ++i)
if(a[i]<=n)
{
index=i;
break;
}
if(index==-1)
return 1;
int cur=a[index];
cur=cur==n?1:cur+1;
for(int j=(index+1)%n; j!=index; j=(j+1)%n,cur=cur==n?1:cur+1)
if(a[j]<=n && a[j] !=cur)
return 0;
return 1;
}
int replacement(int n, int a[], int ans[])
{
vector<int> real(n);
int index=-1, sol=0, cur;
for(int i=0; i<n; ++i)
if(a[i]<=n)
{
real[i]=a[i];
index=i;
break;
}
if(index==-1){
real[0]=1;
index=0;
}
cur=real[index];
cur=cur==n?1:cur+1;
for(int j=(index+1)%n; j!=index; j=(j+1)%n,cur=cur==n?1:cur+1)
real[j]=cur;
vector<pair<int,int>> b;
for(int i=0; i<n; ++i)
if(a[i]>n)
b.emplace_back(a[i],i);
sort(b.begin(),b.end());
int last=n;
for(auto [val,idx]:b)
{
ans[sol++]=real[idx];
for(int i=last+1; i<val; ++i)
ans[sol++]=i;
last=val;
}
return sol;
}
int countReplacement(int n, int T[])
{
}
Compilation message (stderr)
# | 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... |