답안 #576924

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
576924 2022-06-13T19:36:14 Z CSQ31 The Collection Game (BOI21_swaps) C++17
100 / 100
6 ms 396 KB
#include "swaps.h"
#include <bits/stdc++.h>
#define sz(a) (int)(a.size())
#define pb push_back
using namespace std;
int nn,pw = 1;
vector<int>v;
void bitonic(int n){
	if(n==1)return;
	int z = n/2;
	for(int i=0;i<pw;i+=2*z){
		for(int j=i;j<i+z;j++){
			if(max(v[j],v[j+z]) <= nn)schedule(v[j],v[j+z]);
		}
	}
	vector<int>res = visit();
	int k = 0;
	for(int i=0;i<pw;i+=2*z){
		for(int j=i;j<i+z;j++){
			if(max(v[j],v[j+z]) <= nn){
				if(!res[k])swap(v[j],v[j+z]);
				k++;
			}else if(v[j] >nn)swap(v[j],v[j+z]);
		}
	}
	bitonic(n/2);
	
}
void merge(int n){
	if(n==1)return;
	merge(n/2);
	int z = n/2;
	for(int i=0;i<pw;i+=2*z){
		for(int j=i+z;j<i+2*z;j++){
			int inv = j-i-z;
			inv = z-inv-1;
			inv = i+z+inv;
			if(inv > j)swap(v[j],v[inv]);
		}
	}
	bitonic(n);
	
}
void solve(int n,int V){
	nn = n;
	while(pw<n)pw*=2;
	for(int i=1;i<=pw;i++)v.push_back(i);
	merge(pw);
	vector<int>fin;
	for(int x:v)if(x<=n)fin.pb(x);
	answer(fin);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 4 ms 312 KB Correct
5 Correct 5 ms 312 KB Correct
6 Correct 6 ms 308 KB Correct
7 Correct 5 ms 360 KB Correct
8 Correct 5 ms 312 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 4 ms 312 KB Correct
5 Correct 5 ms 308 KB Correct
6 Correct 4 ms 312 KB Correct
7 Correct 4 ms 312 KB Correct
8 Correct 4 ms 312 KB Correct
9 Correct 4 ms 316 KB Correct
10 Correct 6 ms 308 KB Correct
11 Correct 5 ms 312 KB Correct
12 Correct 4 ms 312 KB Correct
13 Correct 4 ms 308 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 1 ms 208 KB Correct
4 Correct 1 ms 208 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 296 KB Correct
4 Correct 4 ms 312 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 296 KB Correct
4 Correct 4 ms 312 KB Correct
5 Correct 1 ms 208 KB Correct
6 Correct 1 ms 208 KB Correct
7 Correct 2 ms 208 KB Correct
8 Correct 5 ms 312 KB Correct
9 Correct 6 ms 312 KB Correct
10 Correct 4 ms 320 KB Correct
11 Correct 4 ms 312 KB Correct
12 Correct 6 ms 308 KB Correct
13 Correct 0 ms 208 KB Correct
14 Correct 1 ms 208 KB Correct
15 Correct 3 ms 300 KB Correct
16 Correct 4 ms 316 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 6 ms 308 KB Correct
5 Correct 4 ms 292 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 6 ms 308 KB Correct
5 Correct 4 ms 292 KB Correct
6 Correct 0 ms 208 KB Correct
7 Correct 1 ms 208 KB Correct
8 Correct 2 ms 304 KB Correct
9 Correct 5 ms 312 KB Correct
10 Correct 5 ms 312 KB Correct
11 Correct 5 ms 312 KB Correct
12 Correct 4 ms 312 KB Correct
13 Correct 4 ms 308 KB Correct
14 Correct 4 ms 312 KB Correct
15 Correct 5 ms 312 KB Correct
16 Correct 4 ms 308 KB Correct
17 Correct 5 ms 312 KB Correct
18 Correct 4 ms 308 KB Correct
19 Correct 0 ms 208 KB Correct
20 Correct 1 ms 208 KB Correct
21 Correct 2 ms 208 KB Correct
22 Correct 4 ms 380 KB Correct
23 Correct 4 ms 316 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 300 KB Correct
4 Correct 4 ms 312 KB Correct
5 Correct 4 ms 308 KB Correct
6 Correct 6 ms 292 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 300 KB Correct
4 Correct 4 ms 312 KB Correct
5 Correct 4 ms 308 KB Correct
6 Correct 6 ms 292 KB Correct
7 Correct 1 ms 208 KB Correct
8 Correct 1 ms 208 KB Correct
9 Correct 2 ms 208 KB Correct
10 Correct 4 ms 304 KB Correct
11 Correct 5 ms 396 KB Correct
12 Correct 5 ms 308 KB Correct
13 Correct 4 ms 312 KB Correct
14 Correct 4 ms 308 KB Correct
15 Correct 4 ms 312 KB Correct
16 Correct 5 ms 308 KB Correct
17 Correct 4 ms 312 KB Correct
18 Correct 5 ms 304 KB Correct
19 Correct 5 ms 312 KB Correct
20 Correct 0 ms 208 KB Correct
21 Correct 1 ms 208 KB Correct
22 Correct 2 ms 208 KB Correct
23 Correct 4 ms 308 KB Correct
24 Correct 5 ms 308 KB Correct
25 Correct 4 ms 288 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 4 ms 312 KB Correct
5 Correct 4 ms 296 KB Correct
6 Correct 4 ms 288 KB Correct
7 Correct 6 ms 292 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 4 ms 312 KB Correct
5 Correct 4 ms 296 KB Correct
6 Correct 4 ms 288 KB Correct
7 Correct 6 ms 292 KB Correct
8 Correct 0 ms 208 KB Correct
9 Correct 0 ms 208 KB Correct
10 Correct 1 ms 208 KB Correct
11 Correct 3 ms 300 KB Correct
12 Correct 5 ms 316 KB Correct
13 Correct 4 ms 312 KB Correct
14 Correct 4 ms 304 KB Correct
15 Correct 4 ms 316 KB Correct
16 Correct 4 ms 312 KB Correct
17 Correct 4 ms 304 KB Correct
18 Correct 4 ms 312 KB Correct
19 Correct 4 ms 312 KB Correct
20 Correct 4 ms 316 KB Correct
21 Correct 4 ms 312 KB Correct
22 Correct 1 ms 208 KB Correct
23 Correct 2 ms 208 KB Correct
24 Correct 2 ms 208 KB Correct
25 Correct 5 ms 312 KB Correct
26 Correct 4 ms 348 KB Correct
27 Correct 4 ms 292 KB Correct
28 Correct 4 ms 292 KB Correct