//
// --- Sample implementation for the task swaps ---
//
// To compile this program with the sample grader, place:
// swaps.h swaps_sample.cpp sample_grader.cpp
// in a single folder and run:
// g++ swaps_sample.cpp sample_grader.cpp
// in this folder.
//
#include "swaps.h"
#include <bits/stdc++.h>
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
using namespace std ;
vector<int> r ;
void solve(int N, int V)
{
vector<int> v(N,-1) ;
vector<int> space(N) ;
iota(all(space), 1 ) ;
int idx_max = 0 ;
while( !space.empty() )
{
vector<int> aux = space ;
while( sz(aux) > 1 )
{
int p = ((sz(aux)+1)/2) ;
for(int i = 0 ; i < sz(aux)/2 ; i++ )
if( i+p < sz(aux) ) schedule(aux[i] , aux[p+i]) ;
r = visit() ;
for(int i = 0 ; i < sz(aux)/2 ; i++ )
if( !r[i] ) aux[i] = aux[i+p] ;
while(sz(aux) > p ) aux.pop_back() ;
}
v[ idx_max++ ] = aux[0] ;
for(int i = 0 ; i < sz(space) ; i++ )
if(space[i] == aux[0])
{
swap(space[i] , space.back() ) ;
space.pop_back() ;
break ;
}
}
answer(v) ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
10 ms |
200 KB |
Correct |
3 |
Correct |
26 ms |
200 KB |
Correct |
4 |
Correct |
86 ms |
296 KB |
Correct |
5 |
Correct |
84 ms |
424 KB |
Correct |
6 |
Correct |
92 ms |
304 KB |
Correct |
7 |
Correct |
83 ms |
300 KB |
Correct |
8 |
Correct |
97 ms |
304 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
10 ms |
296 KB |
Correct |
3 |
Correct |
27 ms |
200 KB |
Correct |
4 |
Correct |
77 ms |
304 KB |
Correct |
5 |
Correct |
78 ms |
300 KB |
Correct |
6 |
Correct |
83 ms |
300 KB |
Correct |
7 |
Correct |
95 ms |
300 KB |
Correct |
8 |
Correct |
80 ms |
304 KB |
Correct |
9 |
Runtime error |
35 ms |
300 KB |
Execution killed with signal 13 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
9 ms |
300 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
9 ms |
300 KB |
Correct |
3 |
Correct |
1 ms |
200 KB |
Correct |
4 |
Correct |
9 ms |
300 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
9 ms |
200 KB |
Correct |
3 |
Correct |
31 ms |
200 KB |
Correct |
4 |
Correct |
82 ms |
552 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
9 ms |
200 KB |
Correct |
3 |
Correct |
31 ms |
200 KB |
Correct |
4 |
Correct |
82 ms |
552 KB |
Correct |
5 |
Correct |
1 ms |
200 KB |
Correct |
6 |
Correct |
10 ms |
200 KB |
Correct |
7 |
Correct |
28 ms |
200 KB |
Correct |
8 |
Correct |
96 ms |
304 KB |
Correct |
9 |
Correct |
90 ms |
300 KB |
Correct |
10 |
Correct |
95 ms |
304 KB |
Correct |
11 |
Correct |
91 ms |
308 KB |
Correct |
12 |
Correct |
88 ms |
412 KB |
Correct |
13 |
Correct |
1 ms |
200 KB |
Correct |
14 |
Correct |
10 ms |
292 KB |
Correct |
15 |
Correct |
27 ms |
300 KB |
Correct |
16 |
Correct |
93 ms |
300 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
8 ms |
200 KB |
Correct |
3 |
Correct |
34 ms |
320 KB |
Correct |
4 |
Correct |
87 ms |
300 KB |
Correct |
5 |
Runtime error |
16 ms |
276 KB |
Execution killed with signal 13 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
8 ms |
200 KB |
Correct |
3 |
Correct |
34 ms |
320 KB |
Correct |
4 |
Correct |
87 ms |
300 KB |
Correct |
5 |
Runtime error |
16 ms |
276 KB |
Execution killed with signal 13 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
10 ms |
200 KB |
Correct |
3 |
Correct |
33 ms |
320 KB |
Correct |
4 |
Correct |
91 ms |
300 KB |
Correct |
5 |
Runtime error |
17 ms |
284 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
10 ms |
200 KB |
Correct |
3 |
Correct |
33 ms |
320 KB |
Correct |
4 |
Correct |
91 ms |
300 KB |
Correct |
5 |
Runtime error |
17 ms |
284 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
9 ms |
296 KB |
Correct |
3 |
Correct |
32 ms |
304 KB |
Correct |
4 |
Correct |
90 ms |
296 KB |
Correct |
5 |
Runtime error |
14 ms |
284 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
9 ms |
296 KB |
Correct |
3 |
Correct |
32 ms |
304 KB |
Correct |
4 |
Correct |
90 ms |
296 KB |
Correct |
5 |
Runtime error |
14 ms |
284 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |