#include "gondola.h"
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define itr ::iterator
const int MAX=1e5;
int arr[MAX],fre[MAX];
int valid(int n,int inputSeq[])
{
int N=n,ok=1;
for(int A=0;A<N;A++)
{
fre[inputSeq[A]]++;
if(fre[inputSeq[A]]>1)
return 0;
}
for(int A=0;A<N;A++)
{
if(inputSeq[A]<=N)
{
ok=0;
inputSeq[A]--;
for(int B=A;B>=0;B--)
{
arr[B]=inputSeq[A];
inputSeq[A]--;
if(inputSeq[A]<0)
inputSeq[A]+=N;
}
inputSeq[A]=arr[A];
for(int B=A+1;B<N;B++)
{
inputSeq[A]++;
if(inputSeq[A]>=N)
inputSeq[A]=0;
arr[B]=inputSeq[A];
}
inputSeq[A]=arr[A]+1;
break;
}
}
if(ok)
return 1;
for(int A=0;A<N;A++)
arr[A]++;
// for(int A=0;A<N;A++)
/// cout<<arr[A]<<" ";
for(int A=0;A<N;A++)
{
// cout<<arr[A]<<" "<<inputSeq[A]<<"\n";
if(inputSeq[A]<=N and arr[A]!=inputSeq[A])
return 0;
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
return -2;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
if(!valid(n,inputSeq))
return 0;
int cnt=0;
vector<int> vec;
for(int A=0;A<n;A++)
vec.pb(inputSeq[A]);
sort(vec.begin(),vec.end());
for(int A=0;A<vec.size();A++)
if(vec[A]==vec[A-1])
return 0;
for(int A=0;A<vec.size();A++)
if(vec[A]>n)
cnt++;
if(cnt==0 or cnt==1 or cnt==3)
return 1;
for(int A=0;A<n;A++)
{
if(inputSeq[A]<=n)
continue;
for(int B=A+1;B<n;B++)
{
if(inputSeq[B]<=n)
continue;
else if(inputSeq[A]<inputSeq[B] or vec.back()-n<3)
return 1;
else
return 2;
}
}
return 2;
}
/*int main()
{
int n,inputSeq[]={1,2,6,7};
cout<<countReplacement(4,inputSeq);
return 0;
}*/
Compilation message
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:81:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int A=0;A<vec.size();A++)
~^~~~~~~~~~~
gondola.cpp:84:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int A=0;A<vec.size();A++)
~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 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 |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
492 KB |
Output is correct |
2 |
Correct |
3 ms |
492 KB |
Output is correct |
3 |
Correct |
2 ms |
492 KB |
Output is correct |
4 |
Correct |
2 ms |
552 KB |
Output is correct |
5 |
Correct |
3 ms |
596 KB |
Output is correct |
6 |
Correct |
9 ms |
1020 KB |
Output is correct |
7 |
Correct |
14 ms |
1276 KB |
Output is correct |
8 |
Correct |
13 ms |
1404 KB |
Output is correct |
9 |
Correct |
5 ms |
1404 KB |
Output is correct |
10 |
Correct |
13 ms |
1532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1532 KB |
Output is correct |
2 |
Correct |
2 ms |
1532 KB |
Output is correct |
3 |
Correct |
3 ms |
1532 KB |
Output is correct |
4 |
Correct |
4 ms |
1532 KB |
Output is correct |
5 |
Correct |
3 ms |
1532 KB |
Output is correct |
6 |
Correct |
8 ms |
1532 KB |
Output is correct |
7 |
Correct |
22 ms |
1532 KB |
Output is correct |
8 |
Correct |
16 ms |
1532 KB |
Output is correct |
9 |
Correct |
5 ms |
1532 KB |
Output is correct |
10 |
Correct |
14 ms |
1532 KB |
Output is correct |
11 |
Correct |
2 ms |
1532 KB |
Output is correct |
12 |
Correct |
2 ms |
1532 KB |
Output is correct |
13 |
Correct |
9 ms |
1532 KB |
Output is correct |
14 |
Correct |
2 ms |
1532 KB |
Output is correct |
15 |
Correct |
16 ms |
1660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
1660 KB |
Integer -2 violates the range [0, 350000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
1660 KB |
Integer -2 violates the range [0, 350000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
1660 KB |
Integer -2 violates the range [0, 350000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1660 KB |
Output is correct |
2 |
Correct |
2 ms |
1660 KB |
Output is correct |
3 |
Correct |
2 ms |
1660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1660 KB |
Output is correct |
2 |
Correct |
2 ms |
1660 KB |
Output is correct |
3 |
Correct |
2 ms |
1660 KB |
Output is correct |
4 |
Correct |
2 ms |
1660 KB |
Output is correct |
5 |
Incorrect |
2 ms |
1660 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1660 KB |
Output is correct |
2 |
Correct |
2 ms |
1660 KB |
Output is correct |
3 |
Correct |
2 ms |
1660 KB |
Output is correct |
4 |
Correct |
2 ms |
1660 KB |
Output is correct |
5 |
Incorrect |
2 ms |
1660 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1660 KB |
Output is correct |
2 |
Correct |
3 ms |
1660 KB |
Output is correct |
3 |
Correct |
2 ms |
1660 KB |
Output is correct |
4 |
Correct |
2 ms |
1660 KB |
Output is correct |
5 |
Incorrect |
2 ms |
1660 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |