Submission #1153089

#TimeUsernameProblemLanguageResultExecution timeMemory
1153089vladiliusGondola (IOI14_gondola)C++20
55 / 100
13 ms2364 KiB
#include <bits/stdc++.h> #include "gondola.h" using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second const int A = 2.5e5; int valid(int n, int x[]){ vector<bool> f(A + 1); int m = 0; for (int i = 0; i < n; i++){ if (f[x[i]]) return 0; f[x[i]] = 1; m = max(m, x[i]); } pii mn = {1e9, 0}; for (int i = 0; i < n; i++) mn = min(mn, {x[i], i}); int p = mn.ss; vector<int> y(n); for (int i = 0; i < n; i++){ int j = i - p; if (j < 0) j += n; y[j] = x[i]; } int X = y[0]; for (int i = 1; i < n; i++){ if (y[i] > n) continue; int Y = y[i] - i; if (Y < 0) Y += n; if (Y != X) return 0; } if (m >= 2 * n) return 1; int cc = 0; for (int i = 1; i <= n; i++) cc += f[i]; if ((n - cc) > (m - n)) return 0; return 1; } int replacement(int n, int a[], int b[]){ int m = 0; for (int i = 0; i < n; i++) m = max(m, a[i]); int p = 0; for (int i = 0; i < n; i++){ if (a[i] <= n){ p = i; } } p = (a[p] - p - 1) % n; if (p < 0) p += n; vector<int> x(n); for (int i = 0; i < n; i++){ int j = i + p; if (j >= n) j -= n; x[j] = a[i]; } vector<pii> all; for (int i = 0; i < n; i++){ if (x[i] > n) all.pb({x[i], i}); } vector<int> f(n); for (int i = 0; i < n; i++) f[i] = i + 1; sort(all.begin(), all.end()); int t = 0; for (auto [v, k]: all){ while (n < v){ b[t++] = f[k]; f[k] = ++n; } } return t; } 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...