# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
389214 | Pichon5 | 곤돌라 (IOI14_gondola) | C++17 | 38 ms | 4660 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include<bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define F first
#define S second
using namespace std;
int valid(int n, int v[])
{
int pos=0;
set<int>st;
for(int i=0;i<n;i++){
if(v[i]<=n){
pos = i- (v[i]-1);
}
if(pos<0)pos+=n;
if(v[i]<=0)return 0;
st.insert(v[i]);
}
if(st.size()!=n)return 0;
for(int i=1;i<=n;i++){
if(v[i]>n)continue;
if(v[pos]!=i)return 0;
pos++;
if(pos==n)pos=0;
}
return 1;
}
//----------------------
int replacement(int n, int v[], int R[])
{
int pos1=0;
for(int i=0;i<n;i++){
if(v[i]<=n){
int B=v[i]-1;
if(i-B>=0){
pos1=i-B;
}else{
B-=i;
pos1=n-B;
}
break;
}
}
int pos=pos1;
vector<pair<int,int> >E;//gondola final y gondola inicial
for(int i=1;i<=n;i++){
E.pb({v[pos],i});
pos++;
if(pos==n)pos=0;
}
sort(E.begin(),E.end());
int next=n+1;
int res=0;
for(int i=0;i<n;i++){
if(E[i].F==E[i].S)continue;
R[res]=E[i].S;next++;res++;
//cout<<"pongo "<<E[i].S<<endl;
int curr=next-1;
while(curr!=E[i].F){
//cout<<"pongo "<<curr<<endl;
R[res]=curr;
curr++;next++;res++;
}
}
//cout<<"respuesta "<<res<<endl;
//cout<<endl;
return res;
}
//----------------------
int countReplacement(int n, int inputSeq[]){
if(not valid(n,inputSeq)){
return 0;
}
long long ans=1;
bool allbreak=true;
for(int i=0;i<n;i++){
if(inputSeq[i]<=n){
allbreak = false;
}
}
if(allbreak){
ans = n;
}
int k = ans;
return k;
}
//number of subtask
//n
//3 1 4
//5 1 2 3 4
//2 3 4 9 6 7 1
컴파일 시 표준 에러 (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... |