제출 #430351

#제출 시각아이디문제언어결과실행 시간메모리
430351frodakcin곤돌라 (IOI14_gondola)C++17
55 / 100
66 ms5252 KiB
#include "gondola.h" #include <cstdio> #include <cassert> #include <map> #include <algorithm> int valid(int n, int inputSeq[]) { std::map<int, int> map; for(int i=0;i<n;++i) { int x=inputSeq[i]-1; if(map.find(x) != map.end()) return 0; map.insert({x, i}); } for(int i=0;i<n;++i) if(map.find(i)!=map.end() && map.find((i+1)%n)!=map.end()) { int u=map[i], v=map[(i+1)%n]; if(v != (u+1)%n) return 0; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { for(int i=0;i<n;++i) if(gondolaSeq[i] <= n && gondolaSeq[i] != i+1) { std::rotate(gondolaSeq, gondolaSeq+(i-gondolaSeq[i]+1+n)%n, gondolaSeq+n); } std::map<int, int> map; for(int i=0;i<n;++i) { int x=gondolaSeq[i]; assert(map.find(x) == map.end()); map.insert({x, i}); } int l=0, v=n; for(auto x:map) for(int t=x.second+1;v<x.first;) replacementSeq[l++]=t, t=++v; return l; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }
#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...