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 "messy.h"
#include <bits/stdc++.h>
using namespace std;
int N; vector<int>ans;
void dfs(int cl, int cr) {
if (cr - cl == 1) return;
string str = ""; for (int i = 0; i < N; i++) str += "1";
for (int i = cl; i < cr; i++) str[i] = '0';
for (int i = cl; i < (cl + cr) / 2; i++) {
string str2 = str; str2[i] = '1';
add_element(str2);
}
dfs(cl, (cl + cr) / 2);
dfs((cl + cr) / 2, cr);
}
void dfs2(int cl, int cr, vector<int>vec1, vector<int>vec2) {
if (cr - cl == 1) { ans[vec1[0]] = cl; return; }
vector<int>E1, E2;
for (int i = 0; i < vec1.size(); i++) {
string str = ""; for (int k = 0; k < N; k++) str += "0";
for (int j = 0; j < vec2.size(); j++) str[vec2[j]] = '1';
str[vec1[i]] = '1';
if (check_element(str) == true) E1.push_back(vec1[i]);
else E2.push_back(vec1[i]);
}
vector<int> G1 = vec2; for (int i = 0; i < E1.size(); i++) G1.push_back(E1[i]);
vector<int> G2 = vec2; for (int i = 0; i < E2.size(); i++) G2.push_back(E2[i]);
dfs2(cl, (cl + cr) / 2, E1, G2);
dfs2((cl + cr) / 2, cr, E2, G1);
}
vector<int> restore_permutation(int n, int w, int r) {
N = n; ans.resize(n, 0);
dfs(0, n);
compile_set();
vector<int> alls; for (int i = 0; i < n; i++) alls.push_back(i);
dfs2(0, n, alls, vector<int>{});
return ans;
}
Compilation message (stderr)
messy.cpp: In function 'void dfs2(int, int, std::vector<int>, std::vector<int>)':
messy.cpp:25:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < vec1.size(); i++) {
~~^~~~~~~~~~~~~
messy.cpp:27:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < vec2.size(); j++) str[vec2[j]] = '1';
~~^~~~~~~~~~~~~
messy.cpp:34:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
vector<int> G1 = vec2; for (int i = 0; i < E1.size(); i++) G1.push_back(E1[i]);
~~^~~~~~~~~~~
messy.cpp:35:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
vector<int> G2 = vec2; for (int i = 0; i < E2.size(); i++) G2.push_back(E2[i]);
~~^~~~~~~~~~~
# | 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... |