답안 #576923

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
576923 2022-06-13T19:35:25 Z CSQ31 The Collection Game (BOI21_swaps) C++17
57 / 100
7 ms 384 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;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+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);
}

Compilation message

swaps.cpp: In function 'void merge(int)':
swaps.cpp:40:6: warning: unused variable 'k' [-Wunused-variable]
   40 |  int k = 0;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 3 ms 208 KB Correct
4 Correct 5 ms 312 KB Correct
5 Correct 6 ms 312 KB Correct
6 Correct 5 ms 308 KB Correct
7 Correct 4 ms 316 KB Correct
8 Correct 6 ms 308 KB Correct
# 결과 실행 시간 메모리 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 5 ms 304 KB Correct
5 Correct 7 ms 312 KB Correct
6 Correct 6 ms 312 KB Correct
7 Correct 5 ms 312 KB Correct
8 Correct 5 ms 312 KB Correct
9 Correct 6 ms 312 KB Correct
10 Correct 6 ms 312 KB Correct
11 Correct 7 ms 308 KB Correct
12 Correct 5 ms 312 KB Correct
13 Correct 5 ms 312 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 Incorrect 1 ms 208 KB Not correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 3 ms 308 KB Correct
4 Correct 6 ms 316 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 3 ms 308 KB Correct
4 Correct 6 ms 316 KB Correct
5 Correct 0 ms 208 KB Correct
6 Correct 1 ms 208 KB Correct
7 Correct 3 ms 300 KB Correct
8 Correct 5 ms 308 KB Correct
9 Correct 5 ms 316 KB Correct
10 Correct 5 ms 308 KB Correct
11 Correct 5 ms 308 KB Correct
12 Correct 5 ms 312 KB Correct
13 Incorrect 1 ms 208 KB Not correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 3 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 7 ms 304 KB Correct
5 Correct 7 ms 292 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 3 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 7 ms 304 KB Correct
5 Correct 7 ms 292 KB Correct
6 Correct 1 ms 208 KB Correct
7 Correct 2 ms 208 KB Correct
8 Correct 4 ms 208 KB Correct
9 Correct 5 ms 312 KB Correct
10 Correct 7 ms 304 KB Correct
11 Correct 6 ms 320 KB Correct
12 Correct 7 ms 312 KB Correct
13 Correct 7 ms 316 KB Correct
14 Correct 5 ms 308 KB Correct
15 Correct 5 ms 312 KB Correct
16 Correct 5 ms 308 KB Correct
17 Correct 5 ms 304 KB Correct
18 Correct 7 ms 312 KB Correct
19 Incorrect 1 ms 208 KB Not correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 304 KB Correct
4 Correct 5 ms 316 KB Correct
5 Correct 7 ms 296 KB Correct
6 Correct 5 ms 296 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 304 KB Correct
4 Correct 5 ms 316 KB Correct
5 Correct 7 ms 296 KB Correct
6 Correct 5 ms 296 KB Correct
7 Correct 0 ms 208 KB Correct
8 Correct 1 ms 304 KB Correct
9 Correct 2 ms 304 KB Correct
10 Correct 6 ms 312 KB Correct
11 Correct 5 ms 312 KB Correct
12 Correct 5 ms 312 KB Correct
13 Correct 7 ms 308 KB Correct
14 Correct 6 ms 308 KB Correct
15 Correct 5 ms 312 KB Correct
16 Correct 5 ms 312 KB Correct
17 Correct 5 ms 312 KB Correct
18 Correct 6 ms 384 KB Correct
19 Correct 5 ms 312 KB Correct
20 Incorrect 1 ms 208 KB Not correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 3 ms 300 KB Correct
4 Correct 5 ms 308 KB Correct
5 Correct 5 ms 308 KB Correct
6 Correct 5 ms 288 KB Correct
7 Runtime error 4 ms 296 KB Execution killed with signal 13
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 3 ms 300 KB Correct
4 Correct 5 ms 308 KB Correct
5 Correct 5 ms 308 KB Correct
6 Correct 5 ms 288 KB Correct
7 Runtime error 4 ms 296 KB Execution killed with signal 13
8 Halted 0 ms 0 KB -