//
// --- 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;
vector<int> merge_sort(vector<int> v, int n){
if(n==1) return v;
vector<int> v1(n/2), v2((n+1)/2);
for(int i=0;i<n/2;i++) v1[i]=v[i];
for(int i=n/2;i<n;i++) v2[i-n/2]=v[i];
v1=merge_sort(v1,n/2);
v2=merge_sort(v2,(n+1)/2);
int p1=0,p2=0,p=0;
while(p1<n/2 || p2<(n+1)/2){
if(p1 == n/2){ v[p++]=v2[p2++]; continue; }
if(p2 == (n+1)/2){ v[p++]=v1[p1++]; continue; }
schedule(v1[p1], v2[p2]);
vector<int> a=visit();
if(a[0] == 1) v[p++] = v1[p1++];
else v[p++]=v2[p2++];
}
return v;
}
void solve(int N, int V) {
int n=N;
vector<int> v(N); for(int i=0;i<N;i++) v[i]=i+1;
//v=merge_sort(v,N);
for(int i=1;i<n;i++){
int j=2;
if(i%2) j=1;
for(int u=j;u<=i;u+=2) schedule(u,u+1);
visit();
}
for(int i=n-2;i>0;i--){
int j=2;
if(i%2) j=1;
for(int u=j;u<=i;u+=2) schedule(u,u+1);
visit();
}
answer(v);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
344 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
344 KB |
Correct |
3 |
Incorrect |
1 ms |
344 KB |
Not correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
344 KB |
Correct |
3 |
Correct |
7 ms |
600 KB |
Correct |
4 |
Correct |
22 ms |
592 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
344 KB |
Correct |
3 |
Correct |
7 ms |
600 KB |
Correct |
4 |
Correct |
22 ms |
592 KB |
Correct |
5 |
Incorrect |
1 ms |
344 KB |
Not correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
2 ms |
440 KB |
Correct |
3 |
Correct |
6 ms |
344 KB |
Correct |
4 |
Correct |
23 ms |
440 KB |
Correct |
5 |
Runtime error |
11 ms |
468 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
2 ms |
440 KB |
Correct |
3 |
Correct |
6 ms |
344 KB |
Correct |
4 |
Correct |
23 ms |
440 KB |
Correct |
5 |
Runtime error |
11 ms |
468 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
2 ms |
344 KB |
Correct |
3 |
Correct |
6 ms |
344 KB |
Correct |
4 |
Correct |
21 ms |
540 KB |
Correct |
5 |
Runtime error |
20 ms |
344 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
2 ms |
344 KB |
Correct |
3 |
Correct |
6 ms |
344 KB |
Correct |
4 |
Correct |
21 ms |
540 KB |
Correct |
5 |
Runtime error |
20 ms |
344 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
432 KB |
Correct |
3 |
Correct |
8 ms |
344 KB |
Correct |
4 |
Correct |
22 ms |
444 KB |
Correct |
5 |
Runtime error |
18 ms |
344 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
432 KB |
Correct |
3 |
Correct |
8 ms |
344 KB |
Correct |
4 |
Correct |
22 ms |
444 KB |
Correct |
5 |
Runtime error |
18 ms |
344 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |