# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
974023 |
2024-05-02T15:24:25 Z |
canadavid1 |
Swap (BOI16_swap) |
C++17 |
|
1000 ms |
592 KB |
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
int main()
{
std::cin.tie(0)->sync_with_stdio(false);
int N;
std::cin >> N;
std::vector<int> v(N);
for(auto& i : v) std::cin >> i;
v.insert(v.begin(),0);
std::vector<int> out(N+1,0);
std::vector<int> ls = v;
// for(auto& i : ls) std::cerr << i;
// std::cerr << "\n";
for(int B = 0; B < 1<<((N)/2); B++)
{
std::vector<int> curr = v;
for(int i = 2; i <=N; i++)
{
bool s;
if (i%2 == 1) s = curr[i/2] > curr[i];
else s = (B>>(i/2-1))&1;
if (s) std::swap(curr[i/2],curr[i]);
}
//if ((N&1)==0 && curr[N] > curr[N/2]) std::swap(curr[N],curr[N/2]);
// for(auto& i : curr) std::cerr << i;
// std::cerr << "\n";
int i = 0;
for(;i <= N && ls[i]==curr[i];i++);
if (curr[i] < ls[i]) ls = curr;
}
ls.erase(ls.begin());
for(auto i : ls) std::cout << i << " ";
std::cout << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
123 ms |
348 KB |
Output is correct |
7 |
Correct |
127 ms |
428 KB |
Output is correct |
8 |
Correct |
122 ms |
344 KB |
Output is correct |
9 |
Correct |
128 ms |
344 KB |
Output is correct |
10 |
Correct |
130 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
123 ms |
348 KB |
Output is correct |
7 |
Correct |
127 ms |
428 KB |
Output is correct |
8 |
Correct |
122 ms |
344 KB |
Output is correct |
9 |
Correct |
128 ms |
344 KB |
Output is correct |
10 |
Correct |
130 ms |
592 KB |
Output is correct |
11 |
Execution timed out |
1052 ms |
348 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
123 ms |
348 KB |
Output is correct |
7 |
Correct |
127 ms |
428 KB |
Output is correct |
8 |
Correct |
122 ms |
344 KB |
Output is correct |
9 |
Correct |
128 ms |
344 KB |
Output is correct |
10 |
Correct |
130 ms |
592 KB |
Output is correct |
11 |
Execution timed out |
1052 ms |
348 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
123 ms |
348 KB |
Output is correct |
7 |
Correct |
127 ms |
428 KB |
Output is correct |
8 |
Correct |
122 ms |
344 KB |
Output is correct |
9 |
Correct |
128 ms |
344 KB |
Output is correct |
10 |
Correct |
130 ms |
592 KB |
Output is correct |
11 |
Execution timed out |
1052 ms |
348 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |