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 <iostream>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <climits>
#include <cassert>
#include <tuple>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
using namespace std;
typedef long long LL;
typedef vector<int> Vi;
typedef vector<LL> VL;
typedef vector<bool> Vb;
typedef vector<vector<int>> Vii;
typedef vector<vector<vector<int>>> Viii;
typedef vector<vector<pair<int, int>>> Vip;
#define forR(i, n) for (int i = 0; i < (n); i++)
void add_element(string x);
void compile_set();
bool check_element(string x);
Vi restore_permutation(int n, int w, int r) {
for (int i = 1; i <= n; i++) {
// i*0 + (n-i)*1
string s;
s.append(i, '0');
s.append(n - i, '1');
add_element(s);
}
compile_set();
string cur; cur.append(n, '1');
Vi p(n);
for (int i = 0; i < n; i++) {
forR(j, n) {
if (cur[j] == '0') continue;
cur[j] = '0';
if (check_element(cur)) {
// j-th is original i
p[j] = i;
break;
}
cur[j] = '1';
}
}
return p;
}
#ifdef TEST_LOCAL
Vi _p { 2,1,3,0 };
set<string> _comp;
void add_element(string x) {
string y;
for (int d : _p) {
y.append(1, x[d]);
}
_comp.insert(y);
}
void compile_set() {}
bool check_element(string x) {
return _comp.count(x) > 0;
}
int main() {
auto r = restore_permutation(4, 16, 16);
return 0;
}
#endif
# | 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... |