제출 #117037

#제출 시각아이디문제언어결과실행 시간메모리
117037davitmargUnscrambling a Messy Bug (IOI16_messy)C++17
38 / 100
3 ms384 KiB
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <bitset>
#include <ctype.h>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()

#ifndef  death
#include "messy.h"
#endif


using namespace std;


#ifdef death

map<string, bool> USED;
vector<int> P;

void add_element(string s)
{
	string t = s;
	for (int i = 0; i < P.size(); i++)
		t[i] = s[P[i]];
	USED[t] = 1;
}

void compile_set()
{

}

bool check_element(string s)
{
	return USED[s];
}

#endif

int n, w, r;
vector<int> p;
bool used[200];
string s;

int Main()
{
	for (int i = 0; i < n; i++)
	{
		s += '0';
		p.PB(0);
	}
	for (int i = 0; i < n; i++)
	{
		s[i] = '1';
		add_element(s);
	}
	compile_set();
	for (int i = 0; i < n; i++)
		s[i] = '0';
	for (int i = 0; i < n; i++)
	{
		vector<int> rnd;
		for (int j = 0; j < n; j++)
			rnd.PB(j);
		random_shuffle(all(rnd));
		random_shuffle(all(rnd));
		random_shuffle(all(rnd));
		for (int J = 0; J < n; J++)
		{
			int j = rnd[J];
			if (used[j])
				continue;
			s[j]++;
			if (check_element(s))
			{
				p[j] = i;
				used[j] = 1;
				break;
			}
			s[j]--;
		}
	}
	return 0;
}

vector<int> restore_permutation(int N, int W, int R)
{
	srand(54684865);
	w = W;
	r = R;
	n = N;
	Main();
	return p;
}


#ifdef death

int main()
{
	int N, R, W;
	cin >> N >> W >> R;
	for (int i = 0; i < N; i++)
	{
		P.PB(0);
		cin >> P.back();
	}
	P = restore_permutation(N, W, R);
	for (int i = 0; i < N; i++)
		cout << P[i] << " ";
	cout << endl;
	return 0;
}

#endif

/*

8 0 0
1 7 3 2 5 0 4 6


*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...