Submission #1108269

#TimeUsernameProblemLanguageResultExecution timeMemory
1108269akzytrUnscrambling a Messy Bug (IOI16_messy)C++17
38 / 100
1 ms508 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
#define ve vector
#define sz(a) ((int)(a).size())

void add_element(std::string x);
bool check_element(std::string x);
void compile_set();

ve<int> restore_permutation(int n, int w, int r) {
	ve<int> p(n, 0);
	string x = "";
	for(int i = 0; i < n; i++) {
		x += '0';
	}
	assert(x.size() == n);

	for(int i = 0; i < n; i++) {
		x[i] = '1';
		add_element(x);
	}

	compile_set();
	x = "";
	for(int i = 0; i < n; i++) {
		x += '0';
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			if(x[j] != '1') {
				x[j] = '1';
				if(check_element(x)) {
					p[j] = i;
					break;
				}
				x[j] = '0';
			}
		}
	}
	return p;
}

/*
How to make better use of the writes?

[0,1,2,3]

1 1 0 0

0 0 1 1


*/

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from messy.cpp:1:
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:18:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |  assert(x.size() == n);
      |         ~~~~~~~~~^~~~
#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...