Submission #1268929

#TimeUsernameProblemLanguageResultExecution timeMemory
1268929kawhietGondola (IOI14_gondola)C++20
35 / 100
9 ms2116 KiB
#include <bits/stdc++.h> #include "gondola.h" using namespace std; int valid(int n, int inputSeq[]) { vector<int> a(n); for (int i = 0; i < n; i++) { a[i] = inputSeq[i]; a[i] %= n; if (a[i] == 0) { a[i] = n; } } for (int i = 1; i < n; i++) { if (a[i] % n != (a[i - 1] + 1) % n) { return 0; } } return 1; } int replacement(int n, int gondolaSeq[], int replacementSeq[]) { vector<pair<int, int>> a(n); vector<int> b(n); for (int i = 0; i < n; i++) { a[i] = {gondolaSeq[i], i}; } vector<int> val(n); iota(val.begin(), val.end(), 1); for (int i = 0; i < n; i++) { if (gondolaSeq[i] <= n) { val[i] = gondolaSeq[i]; for (int j = i - 1; j >= 0; j--) { val[j] = val[j + 1] - 1; if (val[j] == 0) { val[j] = n; } } for (int j = i + 1; j < n; j++) { val[j] = val[j - 1] + 1; if (val[j] == n + 1) { val[j] = 1; } } } break; } sort(a.begin(), a.end()); int j = 0, res = 0, x = n; for (auto [k, i] : a) { int y = val[i]; bool first = 1; while (k > x) { res++; if (first) { first = 0; replacementSeq[j++] = val[i]; } else { replacementSeq[j++] = x; } x++; } } return res; } 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...