# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
798677 |
2023-07-30T22:49:55 Z |
Liudas |
Gondola (IOI14_gondola) |
C++17 |
|
25 ms |
5332 KB |
#include <bits/stdc++.h>
#include "gondola.h"
using namespace std;
int valid(int N, int seq[]){
vector<int> s(2 * N);
set<int> ss;
int val = true;
for(int i = 0; i < N; i ++){
ss.insert(seq[i]);
s[i] = seq[i];
s[i + N] = seq[i];
}
if(ss.size()!=N)val = false;
int start = min_element(s.begin(), s.begin() + N) - s.begin();
int k = *min_element(s.begin(), s.begin() + N);
for(int i = start; i < start + N; i ++, k ++){
if(s[i] <= N && s[i] != k){
val = false;
}
}
return val;
}
int replacement(int N, int seq[], int rseq[]){
vector<int> s(2 * N), ss(2 * N);
vector<pair<int, int>> arr(N);
for(int i = 0; i < N; i ++){
s[i] = seq[i];
s[N+i] = seq[i];
}
int k = min_element(s.begin(), s.begin() + N) - s.begin();
int t = *min_element(s.begin(), s.begin() + N);
for(int i = k; i < k + N; i ++){
ss[i] = (t-1)%N+1;
t++;
}
for(int i = k; i < k + N; i ++){
arr[i-k] = {s[i], ss[i]};
}
int p = 0;
int last = N;
sort(arr.begin(), arr.end());
for(int i = 0; i < N; i ++){
//cout << arr[i].first << " " << arr[i].second << " " << p <<endl;
if(arr[i].first > N){
rseq[p++] = arr[i].second;
for(;++last< arr[i].first;){
rseq[p++] = last;
}
}
}
return p;
}
int countReplacement(int N, int seq[]){
int check = valid(N, seq);
if(!check)return 0;
return 1;
}
Compilation message
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:13:17: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
13 | if(ss.size()!=N)val = false;
| ~~~~~~~~~^~~
# |
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 |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
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 |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
8 ms |
2516 KB |
Output is correct |
7 |
Correct |
20 ms |
4292 KB |
Output is correct |
8 |
Correct |
14 ms |
4400 KB |
Output is correct |
9 |
Correct |
5 ms |
1620 KB |
Output is correct |
10 |
Correct |
19 ms |
5076 KB |
Output is correct |
# |
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 |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
8 ms |
2516 KB |
Output is correct |
7 |
Correct |
19 ms |
4288 KB |
Output is correct |
8 |
Correct |
14 ms |
4480 KB |
Output is correct |
9 |
Correct |
5 ms |
1620 KB |
Output is correct |
10 |
Correct |
19 ms |
5204 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
9 ms |
2260 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
25 ms |
5332 KB |
Output is correct |
# |
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 |
268 KB |
Output is correct |
# |
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 |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 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 |
340 KB |
Output is correct |
# |
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 |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 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 |
340 KB |
Output is correct |
11 |
Correct |
8 ms |
2448 KB |
Output is correct |
12 |
Correct |
9 ms |
2776 KB |
Output is correct |
13 |
Correct |
11 ms |
1492 KB |
Output is correct |
14 |
Correct |
8 ms |
2388 KB |
Output is correct |
15 |
Correct |
19 ms |
2048 KB |
Output is correct |
# |
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 |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
308 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
304 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |