# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
602621 | Vanilla | Gondola (IOI14_gondola) | C++17 | 18 ms | 2588 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 <bits/stdc++.h>
#include "gondola.h"
typedef long long int64;
using namespace std;
int valid(int n, int a[]){
const int maxv = 2e5 + 5e4 + 3;
int mp [maxv] = {};
int in [n];
int ps = -1;
for (int i = 0; i < n; i++){
if (a[i] <= n) ps = i;
}
if (ps == -1){
for (int i = 0; i < n; i++) in[i] = i + 1;
}
else {
for (int i = ps, v = a[ps]; !in[i]; i = (i + 1) % n, v = v % n + 1) in[i] = v;
}
for (int i = 0; i < n; i++){
mp[a[i]]++;
if (mp[a[i]] > 1) return 0;
}
for (int i = 0; i < n; i++){
if (a[i] <= n && a[i] != in[i]) return 0;
}
return 1;
}
//----------------------
int replacement(int n, int a[], int rs[]){
const int maxv = 2e5 + 5e4;
int in[n] = {};
int l = 0;
int ct = n + 1;
int ps = -1;
vector <pair <int, int> > v;
for (int i = 0; i < n; i++){
v.push_back({a[i], i});
if (a[i] <= n) ps = i;
}
sort(v.begin(), v.end());
if (ps == -1){
for (int i = 0; i < n; i++) in[i] = i + 1;
}
else {
for (int i = ps, v = a[ps]; !in[i]; i = (i + 1) % n, v = v % n + 1) in[i] = v;
}
for (auto [val, pos]: v) {
while (in[pos] != val) {
rs[l++] = in[pos];
in[pos] = ct++;
}
}
return l;
}
//----------------------
int countReplacement(int n, int a[]){
const int maxv = 1e6 + 2;
const int64 mod = 1e9 + 9;
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... |