# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
73224 | Batmend4 | Gondola (IOI14_gondola) | C++98 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <iostream>
#include<cstdio>
#include<stack>
#include<vector>
using namespace std;
int valid(int n, int inputSeq[])
{
return -1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int ind = -1;
int ct[n + 5];
stack <int> q;
vector< pair<int, int> >v;
for( int i = 0 ; i < n ; i++ ){
if( gondolaSeq[i] <= n ){
ind = i;
}
}
int nn = n + gondolaSeq[ind] - 1 - ind;
for( int i = 0 ; i < n ; i++ ){
ct[(nn + i) % n] = gondolaSeq[i];
}
for( int i = 0 ; i < n ; i++ ){
v.push_back( make_pair(ct[i], i));
}
sort( v.begin(), v.end());
for( int i = v.size() - 1 ; i >= 0 ; i-- ){
int ct1 = v[i].first;
if( ct1 <= n ) continue;
if( i == 0 ){
int ct2 = v[0].first;
while( ct2 > n ){
q.push( ct2);
ct2--;
}
q.push(v[0].second + 1);
continue;
}
if( v[i - 1].first <= n ){
int ct2 = v[i].first;
while( ct2 > n ){
q.push( ct2);
ct2--;
}
q.push(v[i].second + 1);
continue;
}
while( ct1 > v[i - 1].first){
q.push( ct1);
}
q.push( v[i].second + 1);
}
int ct3 = 0;
while( !q.empty() ){
replacementSeq[ct3] = q.top();
q.pop();
ct3++;
}
return ct3;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}