# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
759713 | raysh07 | Gondola (IOI14_gondola) | C++17 | 24 ms | 5148 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
int valid(int n, int a[])
{
set <int> st;
for (int i = 0; i < n; i++) st.insert(a[i]);
if (st.size() != n) return 0;
vector <int> b;
for (int i = 0; i < n; i++){
if (a[i] <= n) b.push_back(a[i]);
}
for (int i = 1; i < b.size(); i++){
int need = b[i - 1] + 1;
if (need > n) need = 1;
if (b[i] != need) return 0;
}
return 1;
}
//----------------------
int replacement(int n, int a[], int b[])
{
int mx = 0;
for (int i = 0; i < n; i++) mx = max(mx, a[i]);
int mn = 1e6;
int c[n];
for (int i = 0; i < n; i++) mn = min(mn, a[i]);
if (mn > n){
for (int i = 0; i < n; i++) c[i] = i + 1;
} else {
int p = -1;
for (int i = 0; i < n; i++){
if (a[i] <= n) p = i;
}
c[p] = a[p];
for (int i = p + 1; i < n; i++){
c[i] = c[i - 1] + 1;
if (c[i] > n) c[i] = 1;
}
if (p != 0){
c[0] = c[n - 1] + 1;
if (c[0] > n) c[0] = 1;
for (int i = 1; i < p; i++){
c[i] = c[i - 1] + 1;
if (c[i] > n) c[i] = 1;
}
}
}
int l = 0;
set <pair<int, int>> st;
for (int i = 0; i < n; i++){
if (c[i] != a[i]){
st.insert(make_pair(a[i], i));
}
}
int repl = n + 1;
while (st.size()){
auto u = *st.begin();
b[l++] = c[u.second];
c[u.second] = repl++;
if (c[u.second] == a[u.second]) st.erase(u);
}
return l;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |