//
// --- 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>
using namespace std;
const int N=550;
int rrl[N];
vector<pair<int,int>> sch;
void solve(int n, int v) {
// TODO implement this function
for (int i=1;i<=n;i++) rrl[i]=i;
for (int i=2-(n%2);i<=n+1;i++){
for (int j=(i%2)+1;j<n;j+=2){
schedule(rrl[j],rrl[j+1]);
sch.push_back({rrl[j],rrl[j+1]});
}
vector<int> res=visit();
for (int j=0,pos=(i%2)+1;j<res.size();j++,pos+=2){
if (res[j]){
//frnt < back, 60% must
//rrl[j] now has smaller one
}else{
//rrl[j] has bigger one
swap(rrl[pos],rrl[pos+1]);
}
}
sch.clear();
}
/*for (int i=n-1;i>=2;i--){
for (int j=(i%2)+1;j<i;j+=2){
schedule(rrl[j],rrl[j+1]);
sch.push_back({rrl[j],rrl[j+1]});
}
vector<int> res=visit();
for (int j=0,pos=(i%2)+1;j<res.size();j++,pos+=2){
if (res[j]){
//frnt < back, 60% must
//rrl[j] now has smaller one
}else{
//rrl[j] has bigger one
swap(rrl[pos],rrl[pos+1]);
}
}
sch.clear();
}*/
vector<int> ans(n);
for (int i=1;i<=n;i++) ans[i-1]=rrl[i];
answer(ans);
}
Compilation message
swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:26:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for (int j=0,pos=(i%2)+1;j<res.size();j++,pos+=2){
| ~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
3 ms |
304 KB |
Correct |
3 |
Correct |
12 ms |
208 KB |
Correct |
4 |
Correct |
42 ms |
412 KB |
Correct |
5 |
Correct |
45 ms |
312 KB |
Correct |
6 |
Correct |
56 ms |
312 KB |
Correct |
7 |
Correct |
41 ms |
308 KB |
Correct |
8 |
Correct |
62 ms |
312 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
3 ms |
208 KB |
Correct |
3 |
Correct |
12 ms |
208 KB |
Correct |
4 |
Correct |
55 ms |
304 KB |
Correct |
5 |
Correct |
47 ms |
304 KB |
Correct |
6 |
Correct |
43 ms |
308 KB |
Correct |
7 |
Correct |
42 ms |
304 KB |
Correct |
8 |
Correct |
52 ms |
312 KB |
Correct |
9 |
Correct |
53 ms |
360 KB |
Correct |
10 |
Correct |
42 ms |
320 KB |
Correct |
11 |
Correct |
51 ms |
408 KB |
Correct |
12 |
Correct |
47 ms |
312 KB |
Correct |
13 |
Correct |
48 ms |
312 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
3 ms |
304 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
3 ms |
304 KB |
Correct |
3 |
Correct |
1 ms |
208 KB |
Correct |
4 |
Correct |
3 ms |
300 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
4 ms |
304 KB |
Correct |
3 |
Correct |
18 ms |
216 KB |
Correct |
4 |
Correct |
63 ms |
308 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
4 ms |
304 KB |
Correct |
3 |
Correct |
18 ms |
216 KB |
Correct |
4 |
Correct |
63 ms |
308 KB |
Correct |
5 |
Correct |
0 ms |
208 KB |
Correct |
6 |
Correct |
4 ms |
304 KB |
Correct |
7 |
Correct |
14 ms |
208 KB |
Correct |
8 |
Correct |
63 ms |
316 KB |
Correct |
9 |
Correct |
49 ms |
304 KB |
Correct |
10 |
Correct |
48 ms |
304 KB |
Correct |
11 |
Correct |
49 ms |
312 KB |
Correct |
12 |
Correct |
48 ms |
316 KB |
Correct |
13 |
Correct |
1 ms |
208 KB |
Correct |
14 |
Correct |
3 ms |
308 KB |
Correct |
15 |
Correct |
12 ms |
208 KB |
Correct |
16 |
Correct |
49 ms |
312 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Correct |
2 |
Correct |
4 ms |
304 KB |
Correct |
3 |
Correct |
15 ms |
208 KB |
Correct |
4 |
Correct |
45 ms |
380 KB |
Correct |
5 |
Correct |
50 ms |
300 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Correct |
2 |
Correct |
4 ms |
304 KB |
Correct |
3 |
Correct |
15 ms |
208 KB |
Correct |
4 |
Correct |
45 ms |
380 KB |
Correct |
5 |
Correct |
50 ms |
300 KB |
Correct |
6 |
Correct |
1 ms |
208 KB |
Correct |
7 |
Correct |
5 ms |
300 KB |
Correct |
8 |
Correct |
14 ms |
208 KB |
Correct |
9 |
Correct |
45 ms |
308 KB |
Correct |
10 |
Correct |
64 ms |
380 KB |
Correct |
11 |
Correct |
44 ms |
308 KB |
Correct |
12 |
Correct |
51 ms |
308 KB |
Correct |
13 |
Correct |
45 ms |
312 KB |
Correct |
14 |
Correct |
48 ms |
304 KB |
Correct |
15 |
Correct |
54 ms |
312 KB |
Correct |
16 |
Correct |
44 ms |
304 KB |
Correct |
17 |
Correct |
57 ms |
460 KB |
Correct |
18 |
Correct |
42 ms |
308 KB |
Correct |
19 |
Correct |
0 ms |
208 KB |
Correct |
20 |
Correct |
3 ms |
208 KB |
Correct |
21 |
Correct |
13 ms |
208 KB |
Correct |
22 |
Correct |
58 ms |
304 KB |
Correct |
23 |
Correct |
53 ms |
296 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
3 ms |
308 KB |
Correct |
3 |
Correct |
15 ms |
208 KB |
Correct |
4 |
Correct |
45 ms |
316 KB |
Correct |
5 |
Correct |
42 ms |
288 KB |
Correct |
6 |
Runtime error |
9 ms |
284 KB |
Execution killed with signal 13 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
3 ms |
308 KB |
Correct |
3 |
Correct |
15 ms |
208 KB |
Correct |
4 |
Correct |
45 ms |
316 KB |
Correct |
5 |
Correct |
42 ms |
288 KB |
Correct |
6 |
Runtime error |
9 ms |
284 KB |
Execution killed with signal 13 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Correct |
2 |
Correct |
3 ms |
208 KB |
Correct |
3 |
Correct |
17 ms |
208 KB |
Correct |
4 |
Correct |
44 ms |
304 KB |
Correct |
5 |
Correct |
44 ms |
380 KB |
Correct |
6 |
Runtime error |
8 ms |
288 KB |
Execution killed with signal 13 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Correct |
2 |
Correct |
3 ms |
208 KB |
Correct |
3 |
Correct |
17 ms |
208 KB |
Correct |
4 |
Correct |
44 ms |
304 KB |
Correct |
5 |
Correct |
44 ms |
380 KB |
Correct |
6 |
Runtime error |
8 ms |
288 KB |
Execution killed with signal 13 |
7 |
Halted |
0 ms |
0 KB |
- |