Submission #50913

# Submission time Handle Problem Language Result Execution time Memory
50913 2018-06-14T18:16:29 Z zetapi Unscrambling a Messy Bug (IOI16_messy) C++14
20 / 100
4 ms 896 KB
#include "messy.h"
#include "bits/stdc++.h"
using namespace std;
 
#define pb 	push_back

vector<int> res;

int N;

void build(int low,int high)
{
	if(low==high)
	return ;
	string X="";
	int mid=(low+high)/2;
	for(int A=0;A<N;A++)
	{
		if(A<low or A>high)
			X+="1";
		else 
			X+="0";
	}
	for(int A=low;A<=mid;A++)
	{
		X[A]='1';
		add_element(X);
		X[A]='0';
	}
	build(low,mid);
	build(mid+1,high);
	return ;
}

void solve(int low,int high,int mask)
{
	vector<int> present,absent,now;
	for(int B=0;B<N;B++)
	{
		if(mask&(1<<B))
			present.pb(B);
		else
			absent.pb(B);
	}
	if(low==high)
	{
		res[low]=present[0];
		return ;
	}
	string X="";
	for(int A=0;A<N;A++)
		X+="0";
	for(auto A:absent)
		X[A]='1';
	for(int A=0;A<N;A++)
	{
		if(X[A]=='1')
			continue;
		X[A]='1';
		if(check_element(X))
			now.pb(A);
		X[A]='0';
	}
	int mid=(low+high)/2,cur=0;
	for(auto A:now)
		cur^=(1<<A);
	solve(low,mid,cur);
	solve(mid+1,high,mask-cur);
	return ;
}

vector<int> restore_permutation(int n,int w,int r) 
{
    /*add_element("0");
    compile_set();
    check_element("0");*/
    
    N=n;
    res.resize(n);
	build(0,n-1);
	compile_set();
	solve(0,n-1,(1<<n)-1);
    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB n = 8
2 Correct 2 ms 256 KB n = 8
3 Correct 2 ms 384 KB n = 8
4 Correct 2 ms 384 KB n = 8
5 Correct 2 ms 256 KB n = 8
6 Correct 2 ms 256 KB n = 8
7 Correct 2 ms 256 KB n = 8
8 Correct 2 ms 256 KB n = 8
9 Correct 2 ms 256 KB n = 8
10 Correct 2 ms 384 KB n = 8
11 Correct 3 ms 384 KB n = 8
12 Correct 2 ms 256 KB n = 8
13 Correct 2 ms 384 KB n = 8
14 Correct 2 ms 384 KB n = 8
15 Correct 2 ms 252 KB n = 8
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -