Submission #24600

#TimeUsernameProblemLanguageResultExecution timeMemory
24600kdh9949Unscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
4 ms512 KiB
#include <vector>
#include <cstdio>
#include "messy.h"
using namespace std;

int n;
char Q[129];

void f(vector<int> x){
	string q = Q;
    for(auto &i : x) q[i] = '0';
    vector<int> nl, nr;
    for(int i = 0; i < x.size() / 2; i++){
		nl.push_back(x[i]);
        q[x[i]] = '1';
        add_element(q);
        q[x[i]] = '0';
    }
    for(int i = x.size() / 2; i < x.size(); i++) nr.push_back(x[i]);
    if(!nl.empty()){
		f(nl);
		f(nr);
    }
}

void g(vector<int> &ans, vector<int> x, vector<int> y){
	if(x.size() == 1){
		ans[y[0]] = x[0];
		return;
	}
    string q = Q;
	for(auto &i : y) q[i] = '0';
	vector<int> nlx, nly, nrx, nry;
	for(int i = 0; i < x.size() / 2; i++) nlx.push_back(x[i]);
	for(int i = x.size() / 2; i < x.size(); i++) nrx.push_back(x[i]);
	for(int i = 0; i < x.size(); i++){
		q[y[i]] = '1';
		if(check_element(q)) nly.push_back(y[i]);
		else nry.push_back(y[i]);
		q[y[i]] = '0';
	}
	g(ans, nlx, nly);
	g(ans, nrx, nry);
}

vector<int> restore_permutation(int n, int w, int r) {
	vector<int> x;
	for(int i = 0; i < n; i++) x.push_back(i);
	for(int i = 0; i < n; i++) Q[i] = '1';
	f(x);
    compile_set();
	vector<int> ans(n, 0);
	g(ans, x, x);
    return ans;
}

Compilation message (stderr)

messy.cpp: In function 'void f(std::vector<int>)':
messy.cpp:13:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < x.size() / 2; i++){
                    ~~^~~~~~~~~~~~~~
messy.cpp:19:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = x.size() / 2; i < x.size(); i++) nr.push_back(x[i]);
                               ~~^~~~~~~~~~
messy.cpp: In function 'void g(std::vector<int>&, std::vector<int>, std::vector<int>)':
messy.cpp:34:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < x.size() / 2; i++) nlx.push_back(x[i]);
                 ~~^~~~~~~~~~~~~~
messy.cpp:35:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = x.size() / 2; i < x.size(); i++) nrx.push_back(x[i]);
                            ~~^~~~~~~~~~
messy.cpp:36:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < x.size(); i++){
                 ~~^~~~~~~~~~
#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...