# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
73224 | 2018-08-28T05:26:14 Z | Batmend4 | 곤돌라 (IOI14_gondola) | C++ | 0 ms | 0 KB |
#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; }