답안 #434442

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
434442 2021-06-21T10:06:25 Z vanic Unscrambling a Messy Bug (IOI16_messy) C++14
100 / 100
3 ms 480 KB
#include <vector>
#include "messy.h"
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

vector < int > sol;

void pitaj(string s, int l, int d){
	if(l+1==d){
		return;
	}
//	cout << l << ' ' << d << endl;
	int mid=(l+d)/2;
	for(int i=l; i<mid; i++){
		s[i]='1';
		add_element(s);
		s[i]='0';
	}
	for(int i=mid; i<d; i++){
		s[i]='1';
	}
	pitaj(s, l, mid);
	for(int i=mid; i<d; i++){
		s[i]='0';
	}
	for(int i=l; i<mid; i++){
		s[i]='1';
	}
	pitaj(s, mid, d);
}

void rijesi(string s, vector < int > v, int br){
	if(br==1){
		sol.push_back(v[0]);
		return;
	}
	vector < int > v1, v2;
	for(int i=0; i<br; i++){
		s[v[i]]='1';
		if(check_element(s)){
			v1.push_back(v[i]);
		}
		else{
			v2.push_back(v[i]);
		}
		s[v[i]]='0';
	}
	for(int i=0; i<br/2; i++){
		s[v2[i]]='1';
	}
	rijesi(s, v1, br/2);
	for(int i=0; i<br/2; i++){
		s[v2[i]]='0';
	}
	for(int i=0; i<br/2; i++){
		s[v1[i]]='1';
	}
	rijesi(s, v2, br/2);
}

vector < int > kraj;

vector < int > restore_permutation(int n, int w, int r){
	string s;
	for(int i=0; i<n; i++){
		s.push_back('0');
	}
	pitaj(s, 0, n);
	compile_set();
	vector < int > v;
	for(int i=0; i<n; i++){
		v.push_back(i);
	}
	rijesi(s, v, n);
	kraj.resize(n, 0);
	for(int i=0; i<n; i++){
		kraj[sol[i]]=i;
	}
	return kraj;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB n = 8
2 Correct 1 ms 204 KB n = 8
3 Correct 0 ms 204 KB n = 8
4 Correct 1 ms 204 KB n = 8
5 Correct 1 ms 204 KB n = 8
6 Correct 0 ms 204 KB n = 8
7 Correct 1 ms 204 KB n = 8
8 Correct 1 ms 204 KB n = 8
9 Correct 1 ms 204 KB n = 8
10 Correct 1 ms 204 KB n = 8
11 Correct 1 ms 204 KB n = 8
12 Correct 1 ms 204 KB n = 8
13 Correct 0 ms 204 KB n = 8
14 Correct 1 ms 204 KB n = 8
15 Correct 1 ms 204 KB n = 8
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB n = 32
2 Correct 1 ms 204 KB n = 32
3 Correct 1 ms 204 KB n = 32
4 Correct 1 ms 204 KB n = 32
5 Correct 1 ms 204 KB n = 32
6 Correct 1 ms 204 KB n = 32
7 Correct 1 ms 204 KB n = 32
8 Correct 1 ms 204 KB n = 32
9 Correct 1 ms 204 KB n = 32
10 Correct 1 ms 216 KB n = 32
11 Correct 1 ms 204 KB n = 32
12 Correct 1 ms 204 KB n = 32
13 Correct 1 ms 204 KB n = 32
14 Correct 1 ms 204 KB n = 32
15 Correct 1 ms 204 KB n = 32
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB n = 32
2 Correct 1 ms 204 KB n = 32
3 Correct 1 ms 204 KB n = 32
4 Correct 1 ms 204 KB n = 32
5 Correct 1 ms 204 KB n = 32
6 Correct 1 ms 204 KB n = 32
7 Correct 1 ms 204 KB n = 32
8 Correct 1 ms 204 KB n = 32
9 Correct 1 ms 204 KB n = 32
10 Correct 1 ms 204 KB n = 32
11 Correct 1 ms 204 KB n = 32
12 Correct 1 ms 204 KB n = 32
13 Correct 1 ms 204 KB n = 32
14 Correct 1 ms 204 KB n = 32
15 Correct 1 ms 204 KB n = 32
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 460 KB n = 128
2 Correct 2 ms 460 KB n = 128
3 Correct 2 ms 460 KB n = 128
4 Correct 2 ms 460 KB n = 128
5 Correct 2 ms 460 KB n = 128
6 Correct 2 ms 460 KB n = 128
7 Correct 2 ms 460 KB n = 128
8 Correct 2 ms 460 KB n = 128
9 Correct 2 ms 460 KB n = 128
10 Correct 2 ms 460 KB n = 128
11 Correct 2 ms 480 KB n = 128
12 Correct 2 ms 460 KB n = 128
13 Correct 2 ms 460 KB n = 128
14 Correct 1 ms 460 KB n = 128
15 Correct 2 ms 460 KB n = 128
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 460 KB n = 128
2 Correct 3 ms 460 KB n = 128
3 Correct 2 ms 460 KB n = 128
4 Correct 2 ms 460 KB n = 128
5 Correct 2 ms 460 KB n = 128
6 Correct 2 ms 460 KB n = 128
7 Correct 2 ms 460 KB n = 128
8 Correct 2 ms 460 KB n = 128
9 Correct 2 ms 472 KB n = 128
10 Correct 2 ms 460 KB n = 128
11 Correct 2 ms 460 KB n = 128
12 Correct 2 ms 460 KB n = 128
13 Correct 1 ms 460 KB n = 128
14 Correct 2 ms 460 KB n = 128
15 Correct 2 ms 460 KB n = 128