# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
582228 | jasmin | 곤돌라 (IOI14_gondola) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include<gondola.h>
using namespace std;
const int inf=1e9;
vector<int> reorder(int n, vector<int> s){
int small=inf; int ind=-1;
for(int i=0; i<n; i++){
if(s[i]<small){
small=s[i];
ind=i;
}
}
if(n<small){
return s;
}
int start=(n+ind-(small-1))%n;
vector<int> ans(n);
for(int i=0; i<n; i++){
ans[i]=s[(start+i)%n];
}
return ans;
}
int valid(int n, vector<int> s){
s=reorder(n, s);
set<int> used;
for(int i=0; i<n; i++){
if(s[i]!=i+1){
if(s[i]<=n || used.find(s[i])!=used.end()){
return false;
}
used.insert(s[i]);
}
}
return true;
}
/*signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> s(n);
for(int i=0; i<n; i++){
cin >> s[i];
}
cout << valid(n, s) << "\n";
}*/