# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
259933 | srj | 곤돌라 (IOI14_gondola) | C++14 | 96 ms | 9976 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>
using namespace std;
int valid(int n, int inputSeq[])
{
map<int,int> pos;
for(int i =0;i<n;i++){
if(pos.find(inputSeq[i])!=pos.end())
return 0;
pos[inputSeq[i]] = i;
}
int sortSeq[n];
memcpy(sortSeq,inputSeq,sizeof(sortSeq));
sort(sortSeq,sortSeq+n);
if(sortSeq[0]>n)
return 1;
int smallval = sortSeq[0];
int cur = pos[sortSeq[0]];
for(int i =0;i<n;i++){
if(inputSeq[(cur+i)%n]!=smallval+i && inputSeq[(cur+i)%n]<=n){
// cout << smallval << endl;
// cout << i << endl;
return 0;
}
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
map<int,int> pos;
for(int i =0;i<n;i++){
if(pos.find(gondolaSeq[i])!=pos.end())
return 0;
pos[gondolaSeq[i]] = i;
}
int sortSeq[n];
map<int,int> what;
memcpy(sortSeq,gondolaSeq,sizeof(sortSeq));
sort(sortSeq,sortSeq+n);
int pos1 = 0;
if(sortSeq[0]<=n){
pos1 = (n+pos[sortSeq[0]]-sortSeq[0]+1)%n;
}
what[pos1] = 1;
pos[1] = pos1;
for(int i =2;i<=n;i++){
pos[i] = (n+pos1+i-1)%n;
what[pos[i]] = i;
}
int nxt = n+1;
int ans = sortSeq[n-1] - nxt+1;
int j =0;
for(int i =0;i<n;i++){
if(sortSeq[i]>n){
int where = pos[sortSeq[i]];
int prev = what[where];
while(prev!=sortSeq[i]){
replacementSeq[j] = prev;
prev=nxt;
nxt++;
j++;
}
what[where] = prev;
}
}
return ans;
}
//----------------------
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... |