## Submission #582316

# Submission time Handle Problem Language Result Execution time Memory
582316 2022-06-23T16:11:48 Z wdjpng Gondola (IOI14_gondola) C++17
55 / 100
31 ms 4044 KB
```#include "gondola.h"
#include <bits/stdc++.h>

#define int long long
#define rep(i,n) for(int i = 0; i < ((int) n); i++)
#define all(a) a.begin(), a.end()

using namespace std;
int N =1e5+1;

signed valid(signed n, signed inputSeq[])
{
int minn = 251000, mini=-1;
rep(i,n) if((int)inputSeq[i]<minn) {minn=inputSeq[i]; mini=i;}
vector<int>x(n);
rep(i,n) x[(i+minn-1+n)%n]=inputSeq[(i+mini)%n];
rep(i,n) if(x[i]!=i+1&&x[i]<=n) return 0;
vector<int>doub;
rep(i,n) if(x[i]>n) doub.push_back(x[i]);
sort(all(doub));
rep(i,doub.size()-1) if(doub[i]==doub[i+1]) return 0;
return 1;
}

//----------------------

signed replacement(signed n, signed gondseq[], signed replacementSeq[])
{
int minn = 251000, mini=-1;
rep(i,n) if((int)gondseq[i]<minn) {minn=gondseq[i]; mini=i;}
vector<int>x(n);
rep(i,n) x[(i+minn-1+n)%n]=gondseq[(i+mini)%n];

int cur = 0;
int maxx = n;
rep(i,n) maxx=max(maxx,x[i]);
map<int,int>mp;
rep(i,n) if(x[i]>n) mp[x[i]]=i;
auto it = mp.end();
if(mp.size()) it--;

vector<int>out;
vector<int>help(n);
rep(i,n) help[i]=i+1;
for(int i = n+1; i <= maxx; i++)
{
if(mp.count(i)) {out.push_back(help[mp[i]]); help[mp[i]]=i;}
else {out.push_back(help[(*it).second]); help[(*it).second]=i;}
}

rep(i,maxx-n) replacementSeq[i]=out[i];
return maxx-n;
}

//----------------------

signed countReplacement(signed n, signed inputSeq[])
{
return -3;
}
```

### Compilation message

```gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:34:7: warning: unused variable 'cur' [-Wunused-variable]
34 |   int cur = 0;
|       ^~~```

#### Subtask #1 5.0 / 5.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct

#### Subtask #2 5.0 / 5.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 8 ms 1236 KB Output is correct
8 Correct 9 ms 1108 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 9 ms 1252 KB Output is correct

#### Subtask #3 10.0 / 10.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 5 ms 668 KB Output is correct
7 Correct 9 ms 1288 KB Output is correct
8 Correct 8 ms 1052 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 9 ms 1236 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 4 ms 624 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 9 ms 1236 KB Output is correct

#### Subtask #4 5.0 / 5.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct

#### Subtask #5 10.0 / 10.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct

#### Subtask #6 20.0 / 20.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 216 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 8 ms 1748 KB Output is correct
12 Correct 9 ms 2004 KB Output is correct
13 Correct 26 ms 4044 KB Output is correct
14 Correct 9 ms 1824 KB Output is correct
15 Correct 31 ms 3824 KB Output is correct

#### Subtask #7 0 / 5.0

# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -

#### Subtask #8 0 / 15.0

# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -

#### Subtask #9 0 / 15.0

# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -

#### Subtask #10 0 / 10.0

# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -