제출 #194139

#제출 시각아이디문제언어결과실행 시간메모리
194139oscarsierra12곤돌라 (IOI14_gondola)C++14
25 / 100
55 ms4972 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std ; typedef pair<int,int> pii ; int valid(int n, int inputSeq[]) { int x = min_element ( inputSeq, inputSeq+n ) - inputSeq ; vector <int> nwSeq ; set <int> rep ; for ( int i = x ; i < n ; ++i ) nwSeq.push_back ( inputSeq[i] ), rep.insert ( inputSeq[i] ) ; for ( int i = 0 ; i < x ; ++i ) nwSeq.push_back ( inputSeq[i] ), rep.insert ( inputSeq[i] ) ; int expected = inputSeq[x] ; int posible = ( rep.size()==n ) ; for ( int i = 0 ; i < n ; ++i ) { if ( nwSeq[i] <= n ) { if ( nwSeq[i] != expected ) posible = 0 ; expected = nwSeq[i]+1 ; } else expected++ ; } return posible; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { int x = min_element ( gondolaSeq, gondolaSeq+n ) - gondolaSeq ; int beg = 1 ; if ( gondolaSeq[x] <= n ) beg = gondolaSeq[x] ; vector <int> nwSeq ; for ( int i = x ; i < n ; ++i ) nwSeq.push_back ( gondolaSeq[i] ) ; for ( int i = 0 ; i < x ; ++i ) nwSeq.push_back ( gondolaSeq[i] ) ; vector <pii> posib ; for ( int i = 0 ; i < n ; ++i ) { if ( nwSeq[i] != beg ) posib.push_back ( {nwSeq[i], beg} ) ; beg++ ; if ( beg > n ) beg = 1; } sort ( posib.begin(), posib.end() ) ; int ans = 0, id = 0; for ( auto i:posib ) { replacementSeq[id] = i.second ; n++ ; ++ans ; while ( n < i.first ) { ++id ; replacementSeq[id] = n ; ++n ; ++ans ; } } return ans; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }

컴파일 시 표준 에러 (stderr) 메시지

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:15:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   int posible = ( rep.size()==n ) ;
                   ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...