Pagini recente » Cod sursa (job #1180255) | Cod sursa (job #1917554) | Cod sursa (job #2645565) | Cod sursa (job #1530050) | Cod sursa (job #2968681)
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("multimi2.in");
ofstream fout("multimi2.out");
int n;
vector < int > temp1, temp2;
int main() {
fin >> n;
if (n & 1) {
//impar case
int rez = n / 2;
if (rez & 1) {
//caz in care dif = 0;
int i = 1;
temp1.push_back(i);
for (i = 2; i <= rez; i++) {
if (i % 2 == 0) {
temp1.push_back(i);
} else {
temp2.push_back(i);
}
}
temp1.push_back(i);
i++;
temp2.push_back(i);
i++;
while (i <= n) {
if (i & 1) temp1.push_back(i);
else temp2.push_back(i);
i++;
}
fout << 0 << '\n';
fout << temp1.size() << '\n';
for (int i = 0; i < temp1.size(); i++) fout << temp1[i] << " ";
fout << '\n';
fout << temp2.size() << '\n';
for (int i = 0; i < temp2.size(); i++) fout << temp2[i] << " ";
} else {
//caz in care dif = 1;
int i = 1;
temp1.push_back(i);
i++;
while (i <= rez + 1) {
if (i % 2 == 0) {
temp1.push_back(i);
} else {
temp2.push_back(i);
}
i++;
}
while (i <= n) {
if (i % 2 == 0) {
temp2.push_back(i);
} else {
temp1.push_back(i);
}
i++;
}
fout << 1 << '\n';
fout << temp1.size() << '\n';
for (int i = 0; i < temp1.size(); i++) fout << temp1[i] << " ";
fout << '\n';
fout << temp2.size() << '\n';
for (int i = 0; i < temp2.size(); i++) fout << temp2[i] << " ";
}
} else {
int i = 1;
int ret = n / 2;
while (i <= ret) {
if (i & 1) temp1.push_back(i);
else temp2.push_back(i);
i++;
}
while (i <= n) {
if (i & 1) temp2.push_back(i);
else temp1.push_back(i);
i++;
}
fout << 0 << '\n';
fout << temp1.size() << '\n';
for (int i = 0; i < temp1.size(); i++) fout << temp1[i] << " ";
fout << '\n';
fout << temp2.size() << '\n';
for (int i = 0; i < temp2.size(); i++) fout << temp2[i] << " ";
}
// for(int i = 0;i<temp1.size();i++) fout << temp1[i] << ' ';
// fout << '\n';
// for(int i = 0;i<temp2.size();i++) fout << temp2[i] << ' ';
return 0;
}