#include <bits/stdc++.h>
using namespace std;
#include "gondola.h"
int valid(int n, int S[]){
set<int> s; for(int i=0; i<n; i++) s.insert(S[i]); if (s.size()<n) return 0;
int ind = -1;
for (int i=0; i<n; i++) if (S[i] <= n) {ind = i; break;}
if (ind == -1) return 1;
int t = S[ind];
for (int i=ind+1; i!=ind; i++, i%=n){
t++; if (t==n+1) t = 1;
if (S[i] <= n && S[i] != t) return 0;
}
return 1;
}
int replacement(int n, int S[], int replacementSeq[]){
int ind = -1;
for (int i=0; i<n; i++) if (S[i] <= n) {ind = i; break;}
int bg = -1; map<int,int> tr;
if (ind == -1){
for (int i=0; i<n; i++){
tr[S[i]] = i+1; bg= max(bg,S[i]);
}
} else {
int t = S[ind];
for (int i=(ind+1)%n; i!=ind; i++, i%=n){
t++; if (t==n+1) t = 1;
if (S[i] > n) {tr[S[i]] = t; bg=max(bg,S[i]);}
}
}
if (bg==-1) return 0;
int bgm = tr[bg];
tr.erase(bg);
for (int i=n+1; i<=bg; i++){
if (tr.count(i)){
replacementSeq[i-(n+1)] = tr[i];
} else {
replacementSeq[i-(n+1)] = bgm;
bgm = i;
}
}
return (bg-(n+1) + 1);
}
int countReplacement(int n, int inputSeq[]){
return 0;
}
// int main(){
// int n; cin>>n;
// int S[1000];
// for (int i=0; i<n; i++) cin>>S[i];
// int ans[1000];
// int k = replacement(n,S,ans);
// for (int i=0; i<k; i++) cout<<ans[i]<<' ';
// }
Compilation message
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:6:65: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
6 | set<int> s; for(int i=0; i<n; i++) s.insert(S[i]); if (s.size()<n) return 0;
| ~~~~~~~~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
8 ms |
2140 KB |
Output is correct |
7 |
Correct |
20 ms |
3772 KB |
Output is correct |
8 |
Correct |
14 ms |
3928 KB |
Output is correct |
9 |
Correct |
5 ms |
1368 KB |
Output is correct |
10 |
Correct |
18 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Correct |
8 ms |
2136 KB |
Output is correct |
7 |
Correct |
21 ms |
3672 KB |
Output is correct |
8 |
Correct |
15 ms |
3932 KB |
Output is correct |
9 |
Correct |
5 ms |
1372 KB |
Output is correct |
10 |
Correct |
18 ms |
4652 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
9 ms |
2000 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
24 ms |
4692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
588 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
444 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
444 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
496 KB |
Output is correct |
11 |
Correct |
6 ms |
1112 KB |
Output is correct |
12 |
Correct |
7 ms |
1116 KB |
Output is correct |
13 |
Correct |
19 ms |
2716 KB |
Output is correct |
14 |
Correct |
6 ms |
1112 KB |
Output is correct |
15 |
Correct |
21 ms |
3024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |