답안 #889652

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
889652 2023-12-20T04:30:43 Z Jawad_Akbar_JJ Unscrambling a Messy Bug (IOI16_messy) C++14
0 / 100
1 ms 348 KB
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include "messy.h"

using namespace std;
const int N = 2e5 + 10;
int sz;
string ind(int j,string s){
	s[j] = '1';
	return s;
}
int per[N];
// string str[N];
// int cur = 1;
// void add_element(string s){
// 	// cout<<s<<endl;
// 	str[cur++] = s;
// }
// void compile_set(){
// 	// cout<<"compiling set"<<endl;
// 	vector<int> v;
// 	for (int i=1;i<=sz;i++)
// 		v.push_back(i-1);
// 	int k = 50000;
// 	while (k--)
// 		next_permutation(begin(v),begin(v) + sz/2);
// 	k = 50000;
// 	while (k--)
// 		next_permutation(begin(v) + sz/2,end(v));
	
// 	for (int i : v)
// 		cout<<i<<" ";
// 	cout<<endl;

// 	for (int i=1;i<cur;i++){
// 		string s = str[i];
// 		int k = 0;
// 		for (int j : v)
// 			s[k++] = str[i][j];
// 		str[i] = s;
// 		// cout<<str[i]<<endl;
// 	}

// }

// bool check_element(string s){
// 	// cout<<"asked "<<s<<endl;
// 	for (int i=1;i<cur;i++)
// 		if (str[i]==s)
// 			return true;
// 	return false;
// }


vector<int> restore_permutation(int n,int w,int r){
	sz = n;
	string tool;
	for (int i=1;i<=n;i++)
		tool += '.';
	string ask = tool;
	for (int i=n-1;i>=0;i--){
		ask[i] = '1';
		add_element(ask);
	}
	compile_set();
	// cout<<"compiled successfully!"<<endl;

	for (int i=n-1;i>=0;i--){
		for (int j=0;j<n;j++){
			if (tool[j]=='1')
				continue;
			string s = ind(j,tool);
			bool b = check_element(s);
			if (b){
				per[j] = i;
				tool = s;
				break;
			}
		}
	}
	vector<int> v;
	for (int i=0;i<n;i++)
		v.push_back(per[i]);
	return v;
}
// int main(){
// 	vector<int> v = restore_permutation(32,1,1);
// 	for (int i : v)
// 		cout<<i<<" ";
// }
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB grader returned WA
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB grader returned WA
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB grader returned WA
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB grader returned WA
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB grader returned WA
2 Halted 0 ms 0 KB -