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 "bits/stdc++.h"
#include "messy.h"
using namespace std;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#define debug(a) cerr << "(" << #a << ": " << a << ")\n";
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int mxN = 1e5+1, oo = 1e9;
std::vector<int> restore_permutation(int n, int w, int r) {
assert(n==8);
for(int i=1;i<n;++i) {
add_element(string(i,'1')+string(n-i,'0'));
}
vi ans(n);
iota(all(ans),0);
compile_set();
vector<string> got(n);
for(int i=0;i<1<<n;++i) {
string query(n,'0');
int digs = 0;
for(int j=0;j<n;++j) {
if((i>>j) & 1) {
query[j]++;
digs++;
}
}
if(check_element(query)) {
got[digs] = query;
}
}
for(int i=1;i<7;++i) {
int nw = got[i].find('1',i-1);
if(i-1!=nw) {
swap(ans[i-1], ans[nw]);
break;
}
}
return ans;
}
# | 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... |