Submission #931804

#TimeUsernameProblemLanguageResultExecution timeMemory
931804OAleksaGondola (IOI14_gondola)C++14
55 / 100
28 ms6096 KiB
#include "gondola.h" #include <bits/stdc++.h> #define f first #define s second using namespace std; int valid(int n, int input[]) { vector<int> a; for (int i = 0;i < n;i++) a.push_back(input[i]); for (int i = 0;i < n;i++) a.push_back(input[i]); int mn = -1; map<int, int> cnt; for (int i = 0;i < n;i++) { cnt[a[i]]++; if (mn == -1 || a[i] < a[mn]) mn = i; } for (auto u : cnt) { if (u.s > 1) return 0; } for (int i = mn, j = 0;j < n;i++,j++) { if (a[i] > n) continue; if (a[i] != a[mn] + j) return 0; } return 1; } //---------------------- int replacement(int n, int g[], int ans[]) { int sz = 0; if (!valid(n, g)) return sz; vector<int> a; for (int i = 0;i < n;i++) a.push_back(g[i]); for (int i = 0;i < n;i++) a.push_back(g[i]); int mn = -1; for (int i = 0;i < n;i++) { if (a[i] <= n && (mn == -1 || a[i] < a[mn])) mn = i; } vector<pair<int, int>> pos; if (mn == -1) { mn = 0; for (int i = 0;i < n;i++) { if (a[i] < a[mn]) mn = i; } for (int i = mn, j = 1;j <= n;i++, j++) { pos.push_back({a[i], j}); } } else { for (int i = mn, j = 0;j < n;i++, j++) { if (a[i] > n) { int x = a[mn] + j; if (x > n) x -= n; pos.push_back({a[i], x}); } } } sort(pos.begin(), pos.end()); int lst = n; for (auto i : pos) { int br = i.s, x = i.f; while (x > lst) { ans[sz++] = br; br = ++lst; } } return sz; } //---------------------- 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...