# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
50749 |
2018-06-13T06:42:07 Z |
Talant |
Gondola (IOI14_gondola) |
C++17 |
|
27 ms |
2728 KB |
#include "gondola.h"
#include <bits/stdc++.h>
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
using namespace std;
const int N = 2e6 + 5;
int u[N],mx;
int id;
int mn = 1e9 + 7;
vector <pair<int,int> > v;
int valid(int n, int inputSeq[])
{
for (int i = 0; i < n; i ++) {
if (inputSeq[i] < mn)
mn = inputSeq[i],id = i;
mx = max(mx,inputSeq[i]);
}
if (mx > n)
return 0;
int o = mn;
for (int i = id - 1; i >= 0; i --) {
mn --;
if (mn == 0) mn = n;
if (inputSeq[i] > n)
continue;
if (mn != inputSeq[i])
return 0;
}
mn = o;
for (int i = id + 1; i < n; i ++) {
mn ++;
if (mn == n + 1) mn = 1;
if (inputSeq[i] > n)
continue;
if (mn != inputSeq[i])
return 0;
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
for (int i = 0; i < n; i ++) {
if (gondolaSeq[i] < mn)
mn = gondolaSeq[i],id = i;
}
if (mn > n) {
int cn = 0;
for (int i = 0; i < n; i ++)
v.pb(mk(gondolaSeq[i],++cn));
}
else {
int o = mn;
for (int i = id; i >= 0; i --) {
if (gondolaSeq[i] > n) {
v.pb(mk(gondolaSeq[i],mn));
}
mn --;
if (mn == 0)
mn = n;
}
mn = o;
for (int i = id; i < n; i ++) {
if (gondolaSeq[i] > n) {
v.pb(mk(gondolaSeq[i],mn));
}
mn ++;
if (mn == n + 1)
mn = 1;
}
}
sort (v.begin(),v.end());
int last = n + 1;
int cnt = 0;
for (auto to : v) {
replacementSeq[cnt ++] = to.sc;
for (int i = last; i < to.fr; i ++) {
replacementSeq[cnt ++] = i;
}
last = to.fr + 1;
}
return (cnt);
}
//----------------------
vector <int> vec;
int countReplacement(int n, int inputSeq[])
{
return 0;
int cn = 0;
for (int i = 0; i < n; i ++) {
if (mn > inputSeq[i])
mn = inputSeq[i],id = i;
if (inputSeq[i] > n)
cn ++,vec.pb(inputSeq[i]);
}
if (cn != 2) return 1;
sort (vec.begin(),vec.end());
if (vec[0] == n + 1 && vec[1] == n + 2)
return 2;
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
2 ms |
392 KB |
Output is correct |
4 |
Correct |
2 ms |
408 KB |
Output is correct |
5 |
Correct |
2 ms |
408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
464 KB |
Output is correct |
2 |
Correct |
2 ms |
516 KB |
Output is correct |
3 |
Correct |
2 ms |
516 KB |
Output is correct |
4 |
Correct |
2 ms |
592 KB |
Output is correct |
5 |
Correct |
2 ms |
592 KB |
Output is correct |
6 |
Correct |
7 ms |
724 KB |
Output is correct |
7 |
Correct |
14 ms |
844 KB |
Output is correct |
8 |
Correct |
16 ms |
876 KB |
Output is correct |
9 |
Correct |
5 ms |
876 KB |
Output is correct |
10 |
Correct |
13 ms |
876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
876 KB |
Output is correct |
2 |
Correct |
2 ms |
876 KB |
Output is correct |
3 |
Correct |
2 ms |
876 KB |
Output is correct |
4 |
Correct |
2 ms |
876 KB |
Output is correct |
5 |
Correct |
2 ms |
876 KB |
Output is correct |
6 |
Correct |
13 ms |
876 KB |
Output is correct |
7 |
Correct |
14 ms |
892 KB |
Output is correct |
8 |
Correct |
12 ms |
892 KB |
Output is correct |
9 |
Correct |
8 ms |
892 KB |
Output is correct |
10 |
Correct |
14 ms |
892 KB |
Output is correct |
11 |
Correct |
2 ms |
892 KB |
Output is correct |
12 |
Correct |
2 ms |
892 KB |
Output is correct |
13 |
Correct |
9 ms |
892 KB |
Output is correct |
14 |
Correct |
2 ms |
892 KB |
Output is correct |
15 |
Correct |
25 ms |
968 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
968 KB |
Output is correct |
2 |
Correct |
2 ms |
968 KB |
Output is correct |
3 |
Correct |
2 ms |
968 KB |
Output is correct |
4 |
Correct |
2 ms |
968 KB |
Output is correct |
5 |
Correct |
2 ms |
968 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
968 KB |
Output is correct |
2 |
Correct |
2 ms |
968 KB |
Output is correct |
3 |
Correct |
2 ms |
968 KB |
Output is correct |
4 |
Correct |
2 ms |
968 KB |
Output is correct |
5 |
Correct |
2 ms |
968 KB |
Output is correct |
6 |
Correct |
2 ms |
968 KB |
Output is correct |
7 |
Correct |
2 ms |
968 KB |
Output is correct |
8 |
Correct |
3 ms |
968 KB |
Output is correct |
9 |
Correct |
2 ms |
968 KB |
Output is correct |
10 |
Correct |
4 ms |
968 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
968 KB |
Output is correct |
2 |
Correct |
2 ms |
968 KB |
Output is correct |
3 |
Correct |
2 ms |
968 KB |
Output is correct |
4 |
Correct |
2 ms |
968 KB |
Output is correct |
5 |
Correct |
3 ms |
968 KB |
Output is correct |
6 |
Correct |
3 ms |
968 KB |
Output is correct |
7 |
Correct |
3 ms |
968 KB |
Output is correct |
8 |
Correct |
3 ms |
968 KB |
Output is correct |
9 |
Correct |
3 ms |
968 KB |
Output is correct |
10 |
Correct |
2 ms |
968 KB |
Output is correct |
11 |
Correct |
15 ms |
968 KB |
Output is correct |
12 |
Correct |
17 ms |
968 KB |
Output is correct |
13 |
Correct |
17 ms |
1836 KB |
Output is correct |
14 |
Correct |
13 ms |
1836 KB |
Output is correct |
15 |
Correct |
27 ms |
2728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |