Submission #603538

#TimeUsernameProblemLanguageResultExecution timeMemory
6035388e7Gondola (IOI14_gondola)C++17
55 / 100
18 ms2304 KiB
//Challenge: Accepted #include <bits/stdc++.h> using namespace std; #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r){ while (l != r)cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif #define ll long long #define maxn 100005 #define pii pair<int, int> #define ff first #define ss second #include "gondola.h" int valid(int n, int a[]) { int ret = 1, st = -1; for (int i = 0;i < n;i++) { if (a[i] > n) continue; int val = (a[i] - i - 1 + n) % n; if (st == -1) st = val; else if (val != st) { ret = 0; break; } } sort(a, a + n); for (int i = 1;i < n;i++) { if (a[i] == a[i-1]) ret = 0; } return ret; } //---------------------- int replacement(int n, int a[], int ret[]) { int cur = n+1, ind = 0, dif = 0; for (int i = 0;i < n;i++) { if (a[i] <= n) dif = (a[i] - i - 1 + n) % n; } vector<pii> v; for (int i = 0;i < n;i++) { if (a[i] > n) { v.push_back({a[i], i}); a[i] = (dif + i)%n + 1; } } sort(v.begin(), v.end()); for (auto [val, id]:v) { while (cur <= val) { ret[ind++] = a[id]; a[id] = cur++; } } return ind; } //---------------------- 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...