# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
111998 | lauzm0 | Memory 2 (JOI16_memory2) | C++14 | 2 ms | 384 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 "Memory2_lib.h"
#include <iostream>
#include<vector>
#include<cmath>
using namespace std;
void Solve(int T, int 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;
break;
}
if (m < 0) {
break;
}
}
}
if (m < 0) {
cg = false;
}
}
for(int i = 0 ; i <n; i++){
int qqq=-1 ; int qqp=-1;
for(int j = 0 ; j< a.size() ; j++){
if(a[j]==i&&qqq==-1){
qqq=j;
}
else if(a[j]==i && qqq!=-1) {
Answer(qqq,qqp,i);
break;
}
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |