# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
105089 |
2019-04-10T14:14:20 Z |
WLZ |
Gondola (IOI14_gondola) |
C++17 |
|
79 ms |
4728 KB |
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
int valid(int n, int inputSeq[]) {
int pos = -1;
set<int> used;
for (int i = 0; i < n; i++) {
if (used.count(inputSeq[i])) {
return 0;
}
used.insert(inputSeq[i]);
if (inputSeq[i] <= n) {
pos = i;
}
}
if (pos == -1) {
return 1;
}
int cur = inputSeq[pos] - pos;
if (cur < 1) {
cur = n + cur;
}
for (int i = 0; i < n; i++) {
if (inputSeq[i] <= n && inputSeq[i] != cur) {
return 0;
}
cur++;
if (cur > n) {
cur = 1;
}
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
int mx = *max_element(gondolaSeq, gondolaSeq + n);
vector<int> pos(mx + 1, -1);
int st = -1, tmp = -1;
for (int i = 0; i < n; i++) {
pos[gondolaSeq[i]] = i;
if (gondolaSeq[i] > n) {
if (st == -1 || gondolaSeq[i] > gondolaSeq[st]) {
st = i;
}
} else {
tmp = i;
}
}
vector<int> a(n);
if (tmp == -1) {
a[0] = 1;
} else {
a[0] = gondolaSeq[tmp] - tmp;
if (a[0] < 1) {
a[0] = n + a[0];
}
}
for (int i = 1; i < n; i++) {
a[i] = a[i - 1] + 1;
if (a[i] > n) {
a[i] = 1;
}
}
int l = 0;
for (int i = n + 1; i <= mx; i++) {
if (pos[i] == -1) {
replacementSeq[l++] = a[st];
a[st] = i;
} else {
replacementSeq[l++] = a[pos[i]];
a[pos[i]] = i;
}
}
return l;
}
//----------------------
int countReplacement(int n, int inputSeq[]) {
return -3;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
17 ms |
2176 KB |
Output is correct |
7 |
Correct |
13 ms |
640 KB |
Output is correct |
8 |
Correct |
36 ms |
3960 KB |
Output is correct |
9 |
Correct |
12 ms |
1536 KB |
Output is correct |
10 |
Correct |
40 ms |
4472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
20 ms |
2176 KB |
Output is correct |
7 |
Correct |
14 ms |
768 KB |
Output is correct |
8 |
Correct |
31 ms |
3964 KB |
Output is correct |
9 |
Correct |
11 ms |
1536 KB |
Output is correct |
10 |
Correct |
42 ms |
4600 KB |
Output is correct |
11 |
Correct |
2 ms |
444 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Correct |
26 ms |
2168 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
79 ms |
4728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
356 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
1696 KB |
Output is correct |
12 |
Correct |
16 ms |
1920 KB |
Output is correct |
13 |
Correct |
12 ms |
1536 KB |
Output is correct |
14 |
Correct |
13 ms |
1792 KB |
Output is correct |
15 |
Correct |
27 ms |
2332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |