#include "gondola.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> Pll;
typedef long double ldouble;
int vchk[250050] = {};
int valid(int n, int inputSeq[])
{
int L = *max_element(inputSeq, inputSeq + n);
rep(i, L+1) vchk[i] = -1;
rep(i, n) {
if(vchk[inputSeq[i]] != -1) return 0;
vchk[ inputSeq[i] ] = i;
}
pii f = pii(-1, -1);
for(int i=0;i<n;i++) if(inputSeq[i] <= n) f = pii(inputSeq[i], i);
if(f == pii(-1, -1)) return 1;
for(int i=0;i<n;i++) if(inputSeq[i] <= n) {
int exp = (i - f.Se) + f.Fi;
if(exp > n) exp -= n;
if(exp <= 0) exp += n;
if(exp != inputSeq[i]) return 0;
}
return 1;
}
//----------------------
int ep[250050];
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int L = *max_element(gondolaSeq, gondolaSeq + n);
rep(i, L+1) vchk[i] = -1;
rep(i, n) vchk[ gondolaSeq[i] ] = i;
int ret = L - n;
pii f = pii(-1, -1);
for(int i=0;i<n;i++) if(gondolaSeq[i] <= n) f = pii(gondolaSeq[i], i);
if(f == pii(-1, -1)) f = pii(1, 0);
for(int i=0;i<n;i++) {
int exp = (i - f.Se) + f.Fi;
if(exp > n) exp -= n;
if(exp <= 0) exp += n;
ep[i] = exp;
}
int now = ret;
for(int i=L, j=L;i>n;i--) {
while(vchk[j] != -1) --j;
if(j > n || ep[vchk[i]] == j) vchk[j] = vchk[i], replacementSeq[--now] = j;
else {
int t = ep[vchk[i]];
vchk[t] = vchk[i], replacementSeq[--now] = t;
}
}
return ret;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5340 KB |
Output is correct |
2 |
Correct |
0 ms |
5340 KB |
Output is correct |
3 |
Correct |
0 ms |
5340 KB |
Output is correct |
4 |
Correct |
0 ms |
5340 KB |
Output is correct |
5 |
Correct |
0 ms |
5340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5340 KB |
Output is correct |
2 |
Correct |
0 ms |
5340 KB |
Output is correct |
3 |
Correct |
0 ms |
5340 KB |
Output is correct |
4 |
Correct |
0 ms |
5340 KB |
Output is correct |
5 |
Correct |
0 ms |
5340 KB |
Output is correct |
6 |
Correct |
3 ms |
5340 KB |
Output is correct |
7 |
Correct |
13 ms |
5340 KB |
Output is correct |
8 |
Correct |
13 ms |
5340 KB |
Output is correct |
9 |
Correct |
3 ms |
5340 KB |
Output is correct |
10 |
Correct |
6 ms |
5340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5340 KB |
Output is correct |
2 |
Correct |
0 ms |
5340 KB |
Output is correct |
3 |
Correct |
0 ms |
5340 KB |
Output is correct |
4 |
Correct |
0 ms |
5340 KB |
Output is correct |
5 |
Correct |
0 ms |
5340 KB |
Output is correct |
6 |
Correct |
9 ms |
5340 KB |
Output is correct |
7 |
Correct |
9 ms |
5340 KB |
Output is correct |
8 |
Correct |
16 ms |
5340 KB |
Output is correct |
9 |
Correct |
0 ms |
5340 KB |
Output is correct |
10 |
Correct |
9 ms |
5340 KB |
Output is correct |
11 |
Correct |
0 ms |
5340 KB |
Output is correct |
12 |
Correct |
0 ms |
5340 KB |
Output is correct |
13 |
Correct |
3 ms |
5340 KB |
Output is correct |
14 |
Correct |
0 ms |
5340 KB |
Output is correct |
15 |
Correct |
13 ms |
5340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5340 KB |
Output is correct |
2 |
Correct |
0 ms |
5340 KB |
Output is correct |
3 |
Correct |
0 ms |
5340 KB |
Output is correct |
4 |
Correct |
0 ms |
5340 KB |
Output is correct |
5 |
Correct |
0 ms |
5340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5340 KB |
Output is correct |
2 |
Correct |
0 ms |
5340 KB |
Output is correct |
3 |
Correct |
0 ms |
5340 KB |
Output is correct |
4 |
Correct |
0 ms |
5340 KB |
Output is correct |
5 |
Correct |
0 ms |
5340 KB |
Output is correct |
6 |
Correct |
0 ms |
5340 KB |
Output is correct |
7 |
Correct |
0 ms |
5340 KB |
Output is correct |
8 |
Correct |
0 ms |
5340 KB |
Output is correct |
9 |
Correct |
0 ms |
5340 KB |
Output is correct |
10 |
Correct |
0 ms |
5340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5340 KB |
Output is correct |
2 |
Correct |
0 ms |
5340 KB |
Output is correct |
3 |
Correct |
0 ms |
5340 KB |
Output is correct |
4 |
Correct |
0 ms |
5340 KB |
Output is correct |
5 |
Correct |
0 ms |
5340 KB |
Output is correct |
6 |
Correct |
0 ms |
5340 KB |
Output is correct |
7 |
Correct |
0 ms |
5340 KB |
Output is correct |
8 |
Correct |
0 ms |
5340 KB |
Output is correct |
9 |
Correct |
0 ms |
5340 KB |
Output is correct |
10 |
Correct |
0 ms |
5340 KB |
Output is correct |
11 |
Correct |
13 ms |
5340 KB |
Output is correct |
12 |
Correct |
13 ms |
5340 KB |
Output is correct |
13 |
Correct |
13 ms |
5340 KB |
Output is correct |
14 |
Correct |
16 ms |
5340 KB |
Output is correct |
15 |
Correct |
23 ms |
5340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
5340 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
5340 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
5340 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
5340 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |