제출 #652096

#제출 시각아이디문제언어결과실행 시간메모리
652096alvinpiter곤돌라 (IOI14_gondola)C++14
20 / 100
38 ms5120 KiB
#include "gondola.h" #include<bits/stdc++.h> using namespace std; /* * If there is a duplicate, return 0. * If all numbers are > n, return 1. * idxMini -> index of minimum number. If I go around (n - 1) steps starting from idxMini and only consider numbers which is <= n: * These numbers must appear in increasing order * If a and b are two consecutive numbers, then the number of numbers > n in between them must be b - a - 1. */ int valid(int n, int inputSeq[]) { set<int> uniqNumbers; int idxMini = -1; for (int i = 0; i < n; i++) { // There is a duplicate if (uniqNumbers.find(inputSeq[i]) != uniqNumbers.end()) { return 0; } uniqNumbers.insert(inputSeq[i]); if (inputSeq[i] <= n) { if (idxMini == -1 || inputSeq[i] < inputSeq[idxMini]) { idxMini = i; } } } // All numbers are > n. if (idxMini == -1) { return 1; } int lastIdx = idxMini; int cntInBetween = 0; for (int i = (idxMini + 1)%n, step = 1; step <= n - 1; i = (i + 1)%n, step++) { if (inputSeq[i] <= n) { if (inputSeq[i] < inputSeq[lastIdx] || inputSeq[i] - inputSeq[lastIdx] - 1 != cntInBetween) { return 0; } lastIdx = i; cntInBetween = 0; } else { cntInBetween += 1; } } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { return -2; } //---------------------- 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...