# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
72917 |
2018-08-27T08:35:46 Z |
nvmdava |
Gondola (IOI14_gondola) |
C++17 |
|
1000 ms |
5656 KB |
#include "gondola.h"
#include <bits/stdc++.h>
#define MOD 1000000009
using namespace std;
struct Gondola{
int id, val;
Gondola(int _id, int _val){
id = _id;
val = _val;
}
bool operator<(const Gondola& rhs) const{
return val < rhs.val;
}
};
int ord[100001];
map<int, int> in;
vector<Gondola> v;
int valid(int n, int inputSeq[]){
int i;
for(i = 0; i < n; i++){
if(in[inputSeq[i]]) return 0;
in[inputSeq[i]] = 1;
}
for(i = 0; i < n; i++){
if(inputSeq[i] <= n) break;
}
if(i == n) return 1;
int k = inputSeq[i] - 1;
for(int j = 0; j < n; j++){
ord[(k + j) % n] = inputSeq[(i + j) % n];
if((ord[(k + j) % n] != (k + j) % n + 1 && ord[(k + j) % n] <= n) || ord[(k + j) % n] < 1) return 0;
}
for(i = 0; i < n; i++){
if((ord[i] != i + 1 && ord[i] <= n) || ord[i] < 1) return 0;
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
int i;
for(i = 0; i < n; i++){
if(gondolaSeq[i] <= n) break;
}
int k;
if(i == n){
i = 0;
k = 0;
} else {
k = gondolaSeq[i] - 1;
}
for(int j = 0; j < n; j++){
v.push_back(Gondola((k + j) % n + 1, gondolaSeq[(i + j) % n]));
}
sort(v.begin(), v.end());
i = 0;
int s = n + 1;
for(auto x : v){
if(x.val <= n) continue;
replacementSeq[i] = x.id;
i++;
for(; s < x.val; s++){
replacementSeq[i] = s;
i++;
}
s = x.val + 1;
}
return i;
}
//----------------------
long long pow(long long x, int p){
long long s = 1;
while(p > 0){
if(p % 2 == 1){
s *= x;
s %= MOD;
}
x *= x;
x %= MOD;
p /= 2;
}
return s;
}
int countReplacement(int n, int gondolaSeq[]){
int i;
for(i = 0; i < n; i++){
if(gondolaSeq[i] <= n) break;
}
bool in = 0;
int k;
if(i == n){
i = 0;
k = 0;
in = 1;
} else {
k = gondolaSeq[i] - 1;
}
for(int j = 0; j < n; j++){
v.push_back(Gondola((k + j) % n + 1, gondolaSeq[(i + j) % n]));
}
sort(v.begin(), v.end());
i = 0;
long long ans = 1;
int mx = n + 1, mlt = n + 1;
for(auto x : v){
mlt--;
if(x.val < mx) continue;
while(mx < x.val){
ans = ans * mlt % MOD;
mx++;
}
mx = x.val + 1;
}
if(in){
ans = ans * n % MOD;
return (int)ans;
}
return (int) ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
3 ms |
616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
616 KB |
Output is correct |
2 |
Correct |
3 ms |
616 KB |
Output is correct |
3 |
Correct |
3 ms |
616 KB |
Output is correct |
4 |
Correct |
2 ms |
684 KB |
Output is correct |
5 |
Correct |
2 ms |
684 KB |
Output is correct |
6 |
Correct |
21 ms |
2668 KB |
Output is correct |
7 |
Correct |
17 ms |
2668 KB |
Output is correct |
8 |
Correct |
41 ms |
4460 KB |
Output is correct |
9 |
Correct |
19 ms |
4460 KB |
Output is correct |
10 |
Correct |
53 ms |
5108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5108 KB |
Output is correct |
2 |
Correct |
2 ms |
5108 KB |
Output is correct |
3 |
Correct |
2 ms |
5108 KB |
Output is correct |
4 |
Correct |
2 ms |
5108 KB |
Output is correct |
5 |
Correct |
2 ms |
5108 KB |
Output is correct |
6 |
Correct |
21 ms |
5108 KB |
Output is correct |
7 |
Correct |
16 ms |
5108 KB |
Output is correct |
8 |
Correct |
46 ms |
5108 KB |
Output is correct |
9 |
Correct |
13 ms |
5108 KB |
Output is correct |
10 |
Correct |
47 ms |
5108 KB |
Output is correct |
11 |
Correct |
2 ms |
5108 KB |
Output is correct |
12 |
Correct |
2 ms |
5108 KB |
Output is correct |
13 |
Correct |
28 ms |
5108 KB |
Output is correct |
14 |
Correct |
2 ms |
5108 KB |
Output is correct |
15 |
Correct |
79 ms |
5108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
5108 KB |
Output is correct |
2 |
Correct |
2 ms |
5108 KB |
Output is correct |
3 |
Correct |
3 ms |
5108 KB |
Output is correct |
4 |
Correct |
2 ms |
5108 KB |
Output is correct |
5 |
Correct |
2 ms |
5108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5108 KB |
Output is correct |
2 |
Correct |
2 ms |
5108 KB |
Output is correct |
3 |
Correct |
2 ms |
5108 KB |
Output is correct |
4 |
Correct |
3 ms |
5108 KB |
Output is correct |
5 |
Correct |
2 ms |
5108 KB |
Output is correct |
6 |
Correct |
3 ms |
5108 KB |
Output is correct |
7 |
Correct |
3 ms |
5108 KB |
Output is correct |
8 |
Correct |
2 ms |
5108 KB |
Output is correct |
9 |
Correct |
2 ms |
5108 KB |
Output is correct |
10 |
Correct |
3 ms |
5108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
5108 KB |
Output is correct |
2 |
Correct |
2 ms |
5108 KB |
Output is correct |
3 |
Correct |
2 ms |
5108 KB |
Output is correct |
4 |
Correct |
2 ms |
5108 KB |
Output is correct |
5 |
Correct |
2 ms |
5108 KB |
Output is correct |
6 |
Correct |
2 ms |
5108 KB |
Output is correct |
7 |
Correct |
2 ms |
5108 KB |
Output is correct |
8 |
Correct |
3 ms |
5108 KB |
Output is correct |
9 |
Correct |
3 ms |
5108 KB |
Output is correct |
10 |
Correct |
4 ms |
5108 KB |
Output is correct |
11 |
Correct |
19 ms |
5108 KB |
Output is correct |
12 |
Correct |
21 ms |
5108 KB |
Output is correct |
13 |
Correct |
20 ms |
5108 KB |
Output is correct |
14 |
Correct |
17 ms |
5108 KB |
Output is correct |
15 |
Correct |
27 ms |
5108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
5108 KB |
Output is correct |
2 |
Correct |
2 ms |
5108 KB |
Output is correct |
3 |
Correct |
2 ms |
5108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5108 KB |
Output is correct |
2 |
Correct |
3 ms |
5108 KB |
Output is correct |
3 |
Correct |
3 ms |
5108 KB |
Output is correct |
4 |
Correct |
2 ms |
5108 KB |
Output is correct |
5 |
Correct |
2 ms |
5108 KB |
Output is correct |
6 |
Correct |
3 ms |
5108 KB |
Output is correct |
7 |
Correct |
3 ms |
5108 KB |
Output is correct |
8 |
Correct |
2 ms |
5108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
5108 KB |
Output is correct |
2 |
Correct |
3 ms |
5108 KB |
Output is correct |
3 |
Correct |
3 ms |
5108 KB |
Output is correct |
4 |
Correct |
3 ms |
5108 KB |
Output is correct |
5 |
Correct |
2 ms |
5108 KB |
Output is correct |
6 |
Correct |
2 ms |
5108 KB |
Output is correct |
7 |
Correct |
3 ms |
5108 KB |
Output is correct |
8 |
Correct |
3 ms |
5108 KB |
Output is correct |
9 |
Correct |
23 ms |
5108 KB |
Output is correct |
10 |
Correct |
18 ms |
5108 KB |
Output is correct |
11 |
Correct |
9 ms |
5108 KB |
Output is correct |
12 |
Correct |
10 ms |
5108 KB |
Output is correct |
13 |
Correct |
6 ms |
5108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
5108 KB |
Output is correct |
2 |
Correct |
2 ms |
5108 KB |
Output is correct |
3 |
Correct |
1 ms |
5108 KB |
Output is correct |
4 |
Correct |
2 ms |
5108 KB |
Output is correct |
5 |
Correct |
3 ms |
5108 KB |
Output is correct |
6 |
Correct |
2 ms |
5108 KB |
Output is correct |
7 |
Correct |
3 ms |
5108 KB |
Output is correct |
8 |
Correct |
3 ms |
5108 KB |
Output is correct |
9 |
Correct |
25 ms |
5108 KB |
Output is correct |
10 |
Correct |
18 ms |
5108 KB |
Output is correct |
11 |
Correct |
11 ms |
5108 KB |
Output is correct |
12 |
Correct |
14 ms |
5108 KB |
Output is correct |
13 |
Correct |
6 ms |
5108 KB |
Output is correct |
14 |
Execution timed out |
1076 ms |
5656 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |