# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
165010 | kostia244 | 곤돌라 (IOI14_gondola) | C++17 | 49 ms | 4712 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>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
int valid(int n, int a[]) {
set<int> x;
for (int i = 0; i < n; i++)
x.insert(a[i]);
if (x.size() != n)
return 0;
for (int i = 1; i < n; i++) {
if (a[i] > n) {
a[i] = a[i - 1] + 1;
}
}
for (int i = n; i-- > 1;) {
if (a[i] > n) {
a[i] = a[i - 1] == n ? 1 : a[i - 1] + 1;
}
}
int i = 0;
while (a[i] != 1)
i++;
int p = 1;
for (int j = (i + 1) % n; j != i; j = (j + 1) % n) {
if (p+1 != a[j])
return 0;
p = a[j];
}
return 1;
}
//----------------------
int pos[250250];
int replacement(int n, int a[], int b[]) {
int mx = 0, p = 0;
bitset<250250> have;
for(int i = 0; i < n; i++) {
if(a[i]>n) {
have.set(a[i]);
pos[a[i]] = i;
if(a[i]>mx) mx = a[i], p = i;
}
}
for (int i = 1; i < n; i++) {
if (a[i] > n) {
a[i] = (a[i - 1]%n) + 1;
}
}
for (int i = n; i--;) {
if (a[i] > n) {
a[i] = a[i + 1] == 1 ? n : a[i + 1] - 1;
}
}
for(int i = 0; i < n; i++)
if(a[i]>n) exit(-1);
int j = 0;
for(int i = n+1; i <= mx; i++) {
if(have.test(i)) {
b[j++] = a[pos[i]];
a[pos[i]] = i;
} else {
b[j++] = a[p];
a[p] = i;
}
}
return max(0, mx-n);
}
//----------------------
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... |