# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1022464 | TroySer | Unscrambling a Messy Bug (IOI16_messy) | C++17 | 1 ms | 348 KiB |
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;
vector<int> swappedBetween(string s) {
vector<int> perm(s.size());
for (int i = 0; i < s.size(); i++) {
perm[i] = i;
}
vector<int> zeroes, ones;
for (int i = 0; i < s.length(); i++) {
if (s[i] == '0') zeroes.push_back(i);
else ones.push_back(i);
}
for (int i = 0; i < zeroes.size(); i++) {
for (int j = 0; j < ones.size(); j++) {
swap(s[zeroes[i]], s[ones[j]]);
if (check_element(s)) {
swap(perm[zeroes[i]], perm[ones[j]]);
return perm;
}
swap(s[zeroes[i]], s[ones[j]]);
}
}
}
vector<int> restore_permutation(int n, int w, int r) {
string toAdd[n-1];
for (int i = 1; i <= n-1; i++) {
string s = "";
for (int j = 0; j < i; j++) {
s += "1";
}
for (int j = i; j < 8; j++) {
s += "0";
}
toAdd[i - 1] = s;
}
for (int i = 0; i < n-1; i++) {
add_element(toAdd[i]);
}
// add_element("10000000");
// add_element("11000000");
// add_element("11100000");
// add_element("11110000");
// add_element("11111000");
// add_element("11111100");
// add_element("11111110");
compile_set();
vector<int> perm(n);
for (int i = 0; i < n; i++) {
perm[i] = i;
}
for (int i = 0; i < n-1; i++) {
if (!check_element(toAdd[i])) {
return swappedBetween(toAdd[i]);
}
}
return perm;
}
Compilation message (stderr)
# | 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... |