제출 #371262

#제출 시각아이디문제언어결과실행 시간메모리
371262peijar곤돌라 (IOI14_gondola)C++17
55 / 100
47 ms5484 KiB
#include "gondola.h" #include <bits/stdc++.h> #define SZ(v) ((int)(v).size()) using namespace std; using ll = long long; int valid(int n, int inputSeq[]) { set<int> seen; for (int i(0); i < n; ++i) { if (seen.count(inputSeq[i])) return 0; seen.insert(inputSeq[i]); } for (int i(0); i < n; ++i) if (inputSeq[i] <= n) { for (int j(1); j < n; ++j) if (inputSeq[(i+j)%n] <= n and inputSeq[(i+j)%n]%n != (inputSeq[i] + j)%n) return 0; return 1; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { assert(valid(n, gondolaSeq)); int posNormal(0); while (posNormal < n and gondolaSeq[posNormal] > n) posNormal++; if (posNormal != n) rotate(gondolaSeq, gondolaSeq + (posNormal - gondolaSeq[posNormal]+1+n)%n, gondolaSeq + n); vector<pair<int, int>> toReplace; for (int i(0); i < n; ++i) if (gondolaSeq[i] > n) toReplace.emplace_back(gondolaSeq[i]-n, i+1); sort(toReplace.begin(), toReplace.end()); int curLen(0); for (auto [val, id] : toReplace) while (curLen < val) { replacementSeq[curLen++] = id; id = curLen+n; } return curLen; } //---------------------- 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...