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 "messy.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> restore_permutation(int n, int w, int r) {
string guess(8,'0');
vector<string> guesses(8);
vector<int> p(8);
iota(p.begin(),p.end(),0);
string special = "00001111";
for (int ones = 1; ones <= 7; ones++) {
guess[ones] = '1';
guesses[ones] = guess;
add_element(guess);
}
add_element(special);
compile_set();
//cout << check_element("0001111") << "\n";
for (int i = 0; i < 256; i++) {
string toCheck = bitset<8>(i).to_string();
// cout << toCheck << " ";
if (check_element(toCheck)) {
int ones = __builtin_popcount(i);
if (toCheck != guesses[ones] && toCheck != special) {
vector<int> swapped;
for (int bit = 0; bit < 8; bit++) {
if (toCheck[bit] != guesses[ones][bit]) swapped.push_back(bit);
}
if (swapped.size() != 2) {
// cout << toCheck << " " << swapped.size() << " " << ones << "\n";
assert(ones == 4);
swap(p[6],p[7]);
}
else swap(p[swapped[0]],p[swapped[1]]);
break;
}
}
}
//for (int e: p) cout << e << " "; cout << "\n";
return p;
}
# | 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... |