# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1015273 | parsadox2 | Gondola (IOI14_gondola) | C++17 | 24 ms | 5664 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 "gondola.h"
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
int valid(int n, int inputSeq[])
{
int mn_pos = 0;
for(int i = 1 ; i < n ; i++) if(inputSeq[i] < inputSeq[mn_pos])
mn_pos = i;
vector <int> vec;
for(int i = mn_pos ; i < n ; i++)
vec.push_back(inputSeq[i]);
for(int i = 0 ; i < mn_pos ; i++)
vec.push_back(inputSeq[i]);
set <int> st;
for(auto u : vec)
st.insert(u);
if(st.size() != n)
return 0;
bool flg = true;
for(int i = 1 ; i < n ; i++) if(vec[i] <= n && vec[i] - vec[0] != i)
flg = false;
return flg;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int mn_pos = 0;
for(int i = 1 ; i < n ; i++) if(gondolaSeq[i] < gondolaSeq[mn_pos])
mn_pos = i;
vector <int> vec;
for(int i = mn_pos ; i < n ; i++)
vec.push_back(gondolaSeq[i]);
for(int i = 0 ; i < mn_pos ; i++)
vec.push_back(gondolaSeq[i]);
int mx = 0;
for(int i = 0 ; i < n ; i++)
mx = max(mx , vec[i]);
int l = mx - n , pos = 0 , las = n;
vector <pair<int , int>> bad;
for(int i = 0 ; i < n ; i++) if(vec[i] > n)
bad.push_back(make_pair(vec[i] , i));
if(vec[0] > n)
vec[0] = 1;
for(int i = 1 ; i < n ; i++)
{
vec[i] = vec[i - 1] + 1;
if(vec[i - 1] == n)
vec[i] = 1;
}
sort(bad.begin() , bad.end());
for(auto u : bad)
{
while(las < u.F)
{
las++;
replacementSeq[pos] = vec[u.S];
vec[u.S] = las;
pos++;
}
}
return l;
}
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... |