Submission #286673

#TimeUsernameProblemLanguageResultExecution timeMemory
286673mosiashvililukaUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms512 KiB
#include<bits/stdc++.h>
#include "messy.h"
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,p[100009],pas[100009];
vector <int> vpas;
bool bl;
string s;
void cler(string &q){
	q.clear();
	for(int h=0; h<a; h++) q.push_back('0');
}
void rec(int q, int w, string ss){
	if(q==w) return;
	int mid=(q+w)/2;
	string sl=ss;
	for(int h=q; h<=mid; h++){
		sl[h]='1';
		add_element(sl);
		sl[h]='0';
	}
	for(int h=mid+1; h<=w; h++) sl[h]='1';
	rec(q,mid,sl);
	sl=ss;
	for(int h=q; h<=mid; h++) sl[h]='1';
	rec(mid+1,w,sl);
}
void rec2(int q, int w, vector <int> qq, string ss){
	if(q==w){
		p[q]=qq[0];
		return;
	}
	int mid=(q+w)/2;
	string sl=ss;
	vector <int> v,vv;
	for(int h=0; h<qq.size(); h++){
		sl[qq[h]]='1';
		bl=check_element(sl);
		if(bl==1){
			v.push_back(qq[h]);
		}else{
			vv.push_back(qq[h]);
		}
		sl[qq[h]]='0';
	}
	/*for(int h=0; h<v.size(); h++) cout<<v[h]<<" ";
	cout<<endl;
	for(int h=0; h<vv.size(); h++) cout<<vv[h]<<" ";
	cout<<endl;*/
	//for(int h=mid+1; h<=w; h++) sl[h]='1';
	for(int h=0; h<vv.size(); h++) sl[vv[h]]='1';
	rec2(q,mid,v,sl);
	sl=ss;
	//for(int h=q; h<=mid; h++) sl[h]='1';
	for(int h=0; h<v.size(); h++) sl[v[h]]='1';
	rec2(mid+1,w,vv,sl);
}
vector<int> restore_permutation(int nnn, int wwa, int rra) {
	a=nnn;
	vector <int> v;
	for(i=0; i<a; i++) v.push_back(i);
	cler(s);
	rec(0,a-1,s);
	compile_set();
	rec2(0,a-1,v,s);
	for(i=0; i<a; i++){
		pas[p[i]]=i;
	}
	for(i=0; i<a; i++){
		vpas.push_back(pas[i]);
	}
	return vpas;
}

Compilation message (stderr)

messy.cpp: In function 'void rec2(int, int, std::vector<int>, std::string)':
messy.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for(int h=0; h<qq.size(); h++){
      |               ~^~~~~~~~~~
messy.cpp:50:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |  for(int h=0; h<vv.size(); h++) sl[vv[h]]='1';
      |               ~^~~~~~~~~~
messy.cpp:54:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |  for(int h=0; h<v.size(); h++) sl[v[h]]='1';
      |               ~^~~~~~~~~
#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...