#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<map>
#define int long long
using namespace std;
int Ans[105];
int a[105];
vector<int> Index[7];
vector<int> Num[7];
set<int> All;
map<vector<int>, int> mp;
string s;
void Binary(int a) {
if (a > 1) Binary(a / 2);
s += a % 2 + '0';
}
int ask(int i) {
return a[i - 1];
}
vector<int> get_pairwise_xor(vector<int> v) {
vector<int> ans;
for (int i = 0; i < v.size(); i++) {
for (int j = 0; j < v.size(); j++) {
ans.push_back(a[v[i] - 1] ^ a[v[j] - 1]);
}
}
sort(ans.begin(), ans.end());
return ans;
}
void main() {
int n;
cin >> n;
Ans[1] = ask(1);
Index[0].push_back(1);
for (int i = 0; i < 7; i++) {
for (int j = 1; j <= n; j++) {
if (((1 << i) & j) == 0)
Index[i].push_back(j);
}
}
for (int i = 0; i < 7; i++) {
vector<int> v, v1;
v = get_pairwise_xor(Index[i]);
Index[i].erase(Index[i].begin(), Index[i].begin() + 1);
v1 = get_pairwise_xor(Index[i]);
for (int j = 0; j < v.size(); j++) {
if (v[j] == 0) {
v.erase(v.begin(), v.begin() + 1);
j--;
}
}
for (int j = 0; j < v1.size(); j++) {
if (v1[j] == 0) {
v1.erase(v1.begin(), v1.begin() + 1);
j--;
}
}
for (int k = 0; k < v.size(); k++) {
for (int j = 0; j < v1.size(); j++) {
if (v1[j] == v[k]) {
v1.erase(v1.begin() + j, v1.begin() + j + 1);
v.erase(v.begin() + k, v.begin() + k + 1);
k--;
break;
}
}
}
Num[i] = v;
for (int j = 0; j < Num[i].size(); j++) {
Num[i][j] ^= Ans[1];
}
}
for (int i = 0; i < 7; i++) {
for (int j : Num[i]) {
All.insert(j);
}
}
for (int i = 1; i <= n; i++) {
s = "";
Binary(i);
vector<int> v;
int m = s.size();
for (int j = 0; j < 7 - m; j++) {
s = '0' + s;
}
for (int j = 0; j < s.size(); j++) {
if (s[j] == '0') v.push_back(7 - j - 1);
}
reverse(v.begin(), v.end());
mp[v] = i;
}
set<int>::iterator it = All.begin();
while (it != All.end()) {
vector<int> v;
for (int i = 0; i < 7; i++) {
for (int j : Num[i]) {
if (j == *it) {
v.push_back(i);
break;
}
}
}
Ans[mp[v]] = *it;
it++;
}
cout << n << endl;
for (int i = 1; i <= n; i++) {
cout << Ans[i] << ' ';
}
return;
}
Compilation message
Xoractive.cpp: In function 'std::vector<long long int> get_pairwise_xor(std::vector<long long int>)':
Xoractive.cpp:31:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for (int i = 0; i < v.size(); i++) {
| ~~^~~~~~~~~~
Xoractive.cpp:32:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for (int j = 0; j < v.size(); j++) {
| ~~^~~~~~~~~~
Xoractive.cpp: At global scope:
Xoractive.cpp:40:1: error: '::main' must return 'int'
40 | void main() {
| ^~~~
Xoractive.cpp: In function 'int main()':
Xoractive.cpp:61:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | for (int j = 0; j < v.size(); j++) {
| ~~^~~~~~~~~~
Xoractive.cpp:68:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | for (int j = 0; j < v1.size(); j++) {
| ~~^~~~~~~~~~~
Xoractive.cpp:75:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
75 | for (int k = 0; k < v.size(); k++) {
| ~~^~~~~~~~~~
Xoractive.cpp:76:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
76 | for (int j = 0; j < v1.size(); j++) {
| ~~^~~~~~~~~~~
Xoractive.cpp:86:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
86 | for (int j = 0; j < Num[i].size(); j++) {
| ~~^~~~~~~~~~~~~~~
Xoractive.cpp:104:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
104 | for (int j = 0; j < s.size(); j++) {
| ~~^~~~~~~~~~
Xoractive.cpp:128:2: error: return-statement with no value, in function returning 'int' [-fpermissive]
128 | return;
| ^~~~~~