답안 #199025

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
199025 2020-01-28T16:53:09 Z kostia244 Unscrambling a Messy Bug (IOI16_messy) C++17
100 / 100
11 ms 508 KB
#include <bits/stdc++.h>
#include "messy.h"
using namespace std;
string s;
void gen(int l, int r) {
	if(l+1 == r) {
		return;
	}
	int mid = (r+l)>>1;
	for(int i = l; i < mid; i++) {
		s[i] = '1';
		add_element(s);
		s[i] = '0';
	}
	for(int i = l; i < mid; i++) {
		s[i] = '1';
	}
	gen(mid, r);
	for(int i = l; i < mid; i++) {
		s[i] = '0';
	}
	for(int i = mid; i < r; i++) {
		s[i] = '1';
	}
	gen(l, mid);
	for(int i = mid; i < r; i++) {
		s[i] = '0';
	}
}
vector<int> ans;
void get(int l, int r, vector<int> indices) {
	if(l+1 == r) {
		ans[indices[0]] = l;
		return;
	}
	int mid = (l+r)>>1;
	vector<int> a, b;
	for(auto i : indices) {
		s[i] = '1';
		if(check_element(s))
			a.push_back(i);
		else
			b.push_back(i);
		s[i] = '0';
	}
	for(auto i : a) {
		s[i] = '1';
	}
	get(mid, r, b);
	for(auto i : a) {
		s[i] = '0';
	}
	for(auto i : b) {
		s[i] = '1';
	}
	get(l, mid, a);
	for(auto i : b) {
		s[i] = '0';
	}
}
std::vector<int> restore_permutation(int n, int w, int r) {
	s = string(n, '0');
    gen(0, n);
    compile_set();
    ans = vector<int>(n, -1);
    vector<int> ind;
    for(int i = 0; i < n; i++) ind.push_back(i);
    get(0, n, ind);
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB n = 8
2 Correct 5 ms 256 KB n = 8
3 Correct 5 ms 256 KB n = 8
4 Correct 5 ms 376 KB n = 8
5 Correct 5 ms 256 KB n = 8
6 Correct 5 ms 256 KB n = 8
7 Correct 5 ms 256 KB n = 8
8 Correct 5 ms 256 KB n = 8
9 Correct 5 ms 256 KB n = 8
10 Correct 5 ms 256 KB n = 8
11 Correct 5 ms 256 KB n = 8
12 Correct 5 ms 256 KB n = 8
13 Correct 5 ms 256 KB n = 8
14 Correct 5 ms 256 KB n = 8
15 Correct 5 ms 256 KB n = 8
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB n = 32
2 Correct 5 ms 376 KB n = 32
3 Correct 5 ms 376 KB n = 32
4 Correct 5 ms 376 KB n = 32
5 Correct 6 ms 376 KB n = 32
6 Correct 5 ms 376 KB n = 32
7 Correct 6 ms 376 KB n = 32
8 Correct 5 ms 376 KB n = 32
9 Correct 5 ms 376 KB n = 32
10 Correct 5 ms 376 KB n = 32
11 Correct 5 ms 380 KB n = 32
12 Correct 5 ms 376 KB n = 32
13 Correct 5 ms 376 KB n = 32
14 Correct 5 ms 376 KB n = 32
15 Correct 5 ms 376 KB n = 32
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB n = 32
2 Correct 5 ms 376 KB n = 32
3 Correct 5 ms 380 KB n = 32
4 Correct 6 ms 376 KB n = 32
5 Correct 5 ms 376 KB n = 32
6 Correct 5 ms 376 KB n = 32
7 Correct 5 ms 376 KB n = 32
8 Correct 5 ms 376 KB n = 32
9 Correct 6 ms 376 KB n = 32
10 Correct 5 ms 376 KB n = 32
11 Correct 6 ms 376 KB n = 32
12 Correct 5 ms 376 KB n = 32
13 Correct 5 ms 376 KB n = 32
14 Correct 5 ms 376 KB n = 32
15 Correct 5 ms 376 KB n = 32
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 504 KB n = 128
2 Correct 7 ms 504 KB n = 128
3 Correct 7 ms 504 KB n = 128
4 Correct 7 ms 504 KB n = 128
5 Correct 6 ms 504 KB n = 128
6 Correct 7 ms 504 KB n = 128
7 Correct 6 ms 504 KB n = 128
8 Correct 6 ms 504 KB n = 128
9 Correct 9 ms 508 KB n = 128
10 Correct 6 ms 504 KB n = 128
11 Correct 6 ms 504 KB n = 128
12 Correct 6 ms 504 KB n = 128
13 Correct 6 ms 504 KB n = 128
14 Correct 7 ms 504 KB n = 128
15 Correct 6 ms 504 KB n = 128
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 504 KB n = 128
2 Correct 6 ms 504 KB n = 128
3 Correct 6 ms 504 KB n = 128
4 Correct 6 ms 504 KB n = 128
5 Correct 11 ms 504 KB n = 128
6 Correct 7 ms 504 KB n = 128
7 Correct 7 ms 504 KB n = 128
8 Correct 6 ms 504 KB n = 128
9 Correct 6 ms 504 KB n = 128
10 Correct 7 ms 504 KB n = 128
11 Correct 6 ms 504 KB n = 128
12 Correct 6 ms 504 KB n = 128
13 Correct 6 ms 504 KB n = 128
14 Correct 7 ms 504 KB n = 128
15 Correct 6 ms 504 KB n = 128