#include <bits/stdc++.h>
#include "messy.h"
using namespace std;
vector <int> resp;
int m;
void cria(int ini, int fim) {
string s;
//s.clear();
//printf("oi %d %d\n", ini, fim);
if(ini == fim) return;
//printf("oi\n");
//printf("%d\n", m);
s.resize(m);
for(int i = 0; i < m; i++) {
if(i < ini || i > fim) s[i] = '0';
else s[i] = '1';
}
int md = (ini + fim) / 2;
//printf("%d %d\n", ini, md);
for(int i = ini; i <= md; i++) {
s[i] = '0';
//printf("oi1\n");
add_element(s);
//printf("oi2\n");
//cout << s << endl;
s[i] = '1';
}
//printf("%d %d %d %d\n", ini, md, md + 1, fim);
cria(ini, md);
cria(md + 1, fim);
}
string olha;
void responde(int ini, int fim) {
//printf("%d %d\n", ini, fim);
vector <int> esq, dir;
if(ini == fim) {
for(int i = 0; i < m; i++){
if(olha[i] == '1') {
resp[i] = ini;
}
}
return;
}
for(int i = 0; i < m; i++) {
if(olha[i] == '1') {
olha[i] = '0';
if(check_element(olha)) {
esq.push_back(i);
}
else {
dir.push_back(i);
}
olha[i] = '1';
}
}
int md = (ini + fim) / 2;
for(int i = 0; i < dir.size(); i++) olha[dir[i]] = '0';
responde(ini, md);
for(int i = 0; i < dir.size(); i++) olha[dir[i]] = '1';
for(int i = 0; i < esq.size(); i++) olha[esq[i]] = '0';
responde(md + 1, fim);
for(int i = 0; i < esq.size(); i++) olha[esq[i]] = '1';
}
vector<int> restore_permutation(int n, int w, int r) {
m = n;
cria(0, n - 1);
compile_set();
resp.resize(n);
olha.resize(n);
for(int i = 0; i < n; i++) olha[i] = '1';
responde(0, n - 1);
//printf("oi\n");
//for(int i = 0; i < resp.size(); i++) printf("%d ", resp[i]);
//printf("\n");
return resp;
}
Compilation message
messy.cpp: In function 'void responde(int, int)':
messy.cpp:58:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | for(int i = 0; i < dir.size(); i++) olha[dir[i]] = '0';
| ~~^~~~~~~~~~~~
messy.cpp:60:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | for(int i = 0; i < dir.size(); i++) olha[dir[i]] = '1';
| ~~^~~~~~~~~~~~
messy.cpp:61:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | for(int i = 0; i < esq.size(); i++) olha[esq[i]] = '0';
| ~~^~~~~~~~~~~~
messy.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | for(int i = 0; i < esq.size(); i++) olha[esq[i]] = '1';
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n = 8 |
2 |
Correct |
1 ms |
204 KB |
n = 8 |
3 |
Correct |
2 ms |
204 KB |
n = 8 |
4 |
Correct |
1 ms |
204 KB |
n = 8 |
5 |
Correct |
1 ms |
204 KB |
n = 8 |
6 |
Correct |
1 ms |
204 KB |
n = 8 |
7 |
Correct |
1 ms |
204 KB |
n = 8 |
8 |
Correct |
2 ms |
204 KB |
n = 8 |
9 |
Correct |
1 ms |
204 KB |
n = 8 |
10 |
Correct |
1 ms |
288 KB |
n = 8 |
11 |
Correct |
1 ms |
204 KB |
n = 8 |
12 |
Correct |
1 ms |
204 KB |
n = 8 |
13 |
Correct |
1 ms |
204 KB |
n = 8 |
14 |
Correct |
1 ms |
204 KB |
n = 8 |
15 |
Correct |
1 ms |
204 KB |
n = 8 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n = 32 |
2 |
Correct |
1 ms |
204 KB |
n = 32 |
3 |
Correct |
1 ms |
292 KB |
n = 32 |
4 |
Correct |
1 ms |
204 KB |
n = 32 |
5 |
Correct |
1 ms |
204 KB |
n = 32 |
6 |
Correct |
1 ms |
204 KB |
n = 32 |
7 |
Correct |
1 ms |
204 KB |
n = 32 |
8 |
Correct |
1 ms |
204 KB |
n = 32 |
9 |
Correct |
1 ms |
204 KB |
n = 32 |
10 |
Correct |
1 ms |
204 KB |
n = 32 |
11 |
Correct |
1 ms |
204 KB |
n = 32 |
12 |
Correct |
1 ms |
204 KB |
n = 32 |
13 |
Correct |
1 ms |
204 KB |
n = 32 |
14 |
Correct |
1 ms |
204 KB |
n = 32 |
15 |
Correct |
1 ms |
204 KB |
n = 32 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
292 KB |
n = 32 |
2 |
Correct |
1 ms |
204 KB |
n = 32 |
3 |
Correct |
1 ms |
204 KB |
n = 32 |
4 |
Correct |
1 ms |
204 KB |
n = 32 |
5 |
Correct |
1 ms |
292 KB |
n = 32 |
6 |
Correct |
1 ms |
204 KB |
n = 32 |
7 |
Correct |
1 ms |
204 KB |
n = 32 |
8 |
Correct |
1 ms |
204 KB |
n = 32 |
9 |
Correct |
1 ms |
204 KB |
n = 32 |
10 |
Correct |
2 ms |
204 KB |
n = 32 |
11 |
Correct |
1 ms |
204 KB |
n = 32 |
12 |
Correct |
1 ms |
204 KB |
n = 32 |
13 |
Correct |
1 ms |
204 KB |
n = 32 |
14 |
Correct |
1 ms |
204 KB |
n = 32 |
15 |
Correct |
1 ms |
288 KB |
n = 32 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
460 KB |
n = 128 |
2 |
Correct |
3 ms |
424 KB |
n = 128 |
3 |
Correct |
2 ms |
460 KB |
n = 128 |
4 |
Correct |
3 ms |
460 KB |
n = 128 |
5 |
Correct |
2 ms |
420 KB |
n = 128 |
6 |
Correct |
3 ms |
460 KB |
n = 128 |
7 |
Correct |
3 ms |
460 KB |
n = 128 |
8 |
Correct |
3 ms |
460 KB |
n = 128 |
9 |
Correct |
2 ms |
460 KB |
n = 128 |
10 |
Correct |
3 ms |
460 KB |
n = 128 |
11 |
Correct |
2 ms |
460 KB |
n = 128 |
12 |
Correct |
3 ms |
420 KB |
n = 128 |
13 |
Correct |
2 ms |
420 KB |
n = 128 |
14 |
Correct |
2 ms |
460 KB |
n = 128 |
15 |
Correct |
3 ms |
460 KB |
n = 128 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
460 KB |
n = 128 |
2 |
Correct |
3 ms |
460 KB |
n = 128 |
3 |
Correct |
2 ms |
460 KB |
n = 128 |
4 |
Correct |
2 ms |
460 KB |
n = 128 |
5 |
Correct |
3 ms |
460 KB |
n = 128 |
6 |
Correct |
2 ms |
420 KB |
n = 128 |
7 |
Correct |
2 ms |
460 KB |
n = 128 |
8 |
Correct |
2 ms |
460 KB |
n = 128 |
9 |
Correct |
3 ms |
416 KB |
n = 128 |
10 |
Correct |
2 ms |
416 KB |
n = 128 |
11 |
Correct |
2 ms |
460 KB |
n = 128 |
12 |
Correct |
3 ms |
416 KB |
n = 128 |
13 |
Correct |
2 ms |
460 KB |
n = 128 |
14 |
Correct |
2 ms |
484 KB |
n = 128 |
15 |
Correct |
2 ms |
420 KB |
n = 128 |