This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <vector>
#include <set>
#include <iostream>
#include <fstream>
#include "messy.h"
bool exista(std::string s) {
return check_element(s);
}
void change (char &c) {
c = (c == '0'? '1' : '0');
}
std::set<int> where[8];
std::vector<int> restore_permutation(int n, int w, int r) {
int logN = std::__lg(n);
std::vector<int> made;
for(int i = 0; i < logN; i++) {
std::string s(n, '0');
for (const auto &index : made) {
s[index] = '1';
}
if(i == logN - 1) {
s = std::string(n, '1');
}
for(int j = 0; j < n; j++) {
if((j >> i) & 1) {
change(s[j]);
add_element(s);
change(s[j]);
made.push_back(j);
}
}
}
compile_set();
made.clear();
for(int i = 0; i < logN; i++) {
std::string s(n, '0');
for (const auto &index : made) {
s[index] = '1';
}
if(i == logN - 1) {
s = std::string(n, '1');
}
for(int j = 0; j < n; j++) {
change(s[j]);
if(exista(s)) {
where[i].insert(j);
made.push_back(j);
}
change(s[j]);
}
}
std::vector<int> p(n, 0);
for(int i = 0; i < n; i++) {
for(int j = 0; j < logN; j++)
if(where[j].count(i))
p[i] |= (1 << j);
}
return p;
}
/**
4 16 16
2 1 3 0
**/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |