# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
838393 | MohamedAhmed04 | Gondola (IOI14_gondola) | C++14 | 26 ms | 5332 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 ;
const int MAX = 3e5 + 10 ;
int arr[MAX] ;
int valid(int n, int inputSeq[])
{
for(int i = 0 ; i < 2*n ; ++i)
arr[i] = inputSeq[i%n] ;
set<int>s ;
for(int i = 0 ; i < n ; ++i)
s.insert(arr[i]) ;
if(s.size() != n)
return 0 ;
int idx = -1 ;
for(int i = 0 ; i < n ; ++i)
{
if(arr[i] <= n)
idx = i ;
}
if(idx == -1)
return 1 ;
int now = arr[idx]-1 ;
for(int i = idx ; i < idx+n ; ++i)
{
++now ;
if(now == n+1)
now = 1 ;
if(arr[i] != now && arr[i] <= n)
return 0 ;
}
return 1 ;
}
//----------------------
int mark[MAX] ;
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
for(int i = 0 ; i < 2*n ; ++i)
arr[i] = gondolaSeq[i%n] ;
int idx = -1 ;
for(int i = 0 ; i < n ; ++i)
{
if(arr[i] <= n)
idx = i ;
}
int Max = *max_element(arr , arr + n) ;
for(int i = 0 ; i < n ; ++i)
mark[arr[i]] = 1 ;
vector< pair<int , int> >vp ;
if(idx == -1)
{
for(int i = 0 ; i < n ; ++i)
vp.emplace_back(arr[i] , i+1) ;
}
else
{
int now = arr[idx] - 1 ;
for(int i = idx ; i < idx+n ; ++i)
{
++now ;
if(now == n+1)
now = 1 ;
if(arr[i] > n)
vp.emplace_back(arr[i] , now) ;
}
}
sort(vp.begin() , vp.end()) ;
idx = 0 ;
int prv = n ;
for(auto &p : vp)
{
replacementSeq[idx] = p.second , ++idx ;
for(int i = prv+1 ; i < p.first ; ++i)
replacementSeq[idx] = i , ++idx ;
prv = p.first ;
}
return idx ;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
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... |