# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
111970 | lauzm0 | Memory 2 (JOI16_memory2) | C++14 | 0 ms | 0 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 <iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
int n; cin >> n; vector<int>pp(2 * n); vector<int>rp; vector<vector<int>>flip1(2*n);
for (int i = 0; i < 2*n; i++) {
vector<int>p(n + 1, 0);
for (int j = 0; j < 2*n; j++) {
if (i != j) {
p[flip(i,j)]++;
flip1[i].push_back(flip(i,j));
}
}
for (int j = 0; j < n; j++) {
if (p[j] % 2 == 1) {
pp[p[j]] = j;
}
}
}
for (int i = 2 * n - 1; i > 0; i = i - 2) {
rp.push_back(pp[i]);
}
int m = n - 1;
int jk = 1;
vector<int>a(2 * n); int counter = 2; bool cg = true;
while (cg) {
for (int i = 0; i < 2 * n; i++) {
int count = 0;
for (int j = 0; j < flip1[i].size(); j++) {
if (flip1[i][j] == rp[m]) {
count++;
}
}
if (count == jk) {
a[i] = rp[m];
counter--;
if (counter == 0) {
jk = jk + 2;
m--;
counter = 2;
}
if (m < 0) {
break;
}
}
}
if (m < 0) {
cg = false;
}
}
for (int i = 0; i < a.size(); i++) {
cout << a[i] << " ";
}
}