#include<bits/stdc++.h>
#include "gondola.h"
using namespace std;
int valid(int n, int inputSeq[])
{
set<int> uniq={};
for(int i=0;i<n;i++)
uniq.insert(inputSeq[i]);
if(uniq.size()!=n)return 0;
int mini=0;
for(int i=1;i<n;i++)
if(inputSeq[mini]>inputSeq[i])mini=i;
int ind=(mini+1)%n;
int value=-1;
int target=inputSeq[mini];
while(ind!=mini)
{
value=inputSeq[ind];
target++;
if(value<target)return 0;
ind=(ind+1)%n;
}
return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
return -1;
}
int countReplacement(int n, int inputSeq[])
{
return -1;
}
/*
int n=6;
int v[]={3, 4, 5, 6, 1, 2} ;
int main()
{
cout<<valid(n,v)<<endl;
}
*/
Compilation message
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:9:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(uniq.size()!=n)return 0;
~~~~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
3 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
636 KB |
Output is correct |
2 |
Correct |
2 ms |
636 KB |
Output is correct |
3 |
Correct |
3 ms |
636 KB |
Output is correct |
4 |
Correct |
2 ms |
656 KB |
Output is correct |
5 |
Correct |
3 ms |
656 KB |
Output is correct |
6 |
Correct |
18 ms |
2828 KB |
Output is correct |
7 |
Correct |
40 ms |
4696 KB |
Output is correct |
8 |
Correct |
33 ms |
5336 KB |
Output is correct |
9 |
Correct |
11 ms |
5336 KB |
Output is correct |
10 |
Correct |
38 ms |
6580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6580 KB |
Output is correct |
2 |
Correct |
2 ms |
6580 KB |
Output is correct |
3 |
Correct |
2 ms |
6580 KB |
Output is correct |
4 |
Correct |
2 ms |
6580 KB |
Output is correct |
5 |
Correct |
2 ms |
6580 KB |
Output is correct |
6 |
Correct |
21 ms |
6580 KB |
Output is correct |
7 |
Correct |
42 ms |
6580 KB |
Output is correct |
8 |
Correct |
32 ms |
7148 KB |
Output is correct |
9 |
Correct |
12 ms |
7148 KB |
Output is correct |
10 |
Correct |
37 ms |
8320 KB |
Output is correct |
11 |
Correct |
3 ms |
8320 KB |
Output is correct |
12 |
Incorrect |
2 ms |
8320 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
8320 KB |
Integer -1 violates the range [0, 350000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
8320 KB |
Integer -1 violates the range [0, 350000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
8320 KB |
Integer -1 violates the range [0, 350000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
8320 KB |
Integer -1 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
8320 KB |
Integer -1 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
8320 KB |
Integer -1 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
8320 KB |
Integer -1 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |