제출 #238430

#제출 시각아이디문제언어결과실행 시간메모리
238430lakshith_곤돌라 (IOI14_gondola)C++14
20 / 100
50 ms4728 KiB
#include <bits/stdc++.h> #include "gondola.h" using namespace std; set<int> visited; int valid(int n,int input[]){ for(int i=0;i<n;i++) if(visited.find(input[i])!=visited.end()) return 0; else visited.insert(input[i]); int start = -1; for(int i=0;i<n;i++)if(input[i]<=n){ start = i; break; } if(start==-1)return 1; int next = input[start]; int pos = start; for(int i=0;i<n;i++){ if(input[pos]<=n&&input[pos]!=next)return 0; pos++; if(pos>=n)pos=0; next++; if(next>n)next=1; } return 1; } int replacement(int n, int gondolaSeq[], int replacementSeq[]){ int start = 0; for(int i=0;i<n;i++){ if(gondolaSeq[i]<=n){start = i;break;} } int next = gondolaSeq[start]<=n?gondolaSeq[start]:1; vector<pair<int,int>> vec; int pos = 0; for(int i=0;i<n;i++){ vec.push_back({gondolaSeq[pos++],next++}); if(next>n)next = 1; if(pos>=n)pos=0; } sort(vec.begin(),vec.end()); int last = n; int l = 0; for(int i=0;i<n;i++){ while(vec.at(i).first != vec.at(i).second){ replacementSeq[l++] = vec.at(i).second; vec.at(i).second = ++last; } } return l; } int countReplacement(int n, int inputSeq[]){ return 0; }
#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...