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 <bits/stdc++.h>
using namespace std;
void Solve(int T, int N){
vector<int> cands = {0, 1, 2}, res(2 * N);
vector his(2 * N, vector<int>(2 * N, -1));
auto flip = [&](int i, int j) {
if (his[i][j] != -1) {
return his[i][j];
}
return his[i][j] = his[j][i] = Flip(i, j);
};
auto extract = [&]() {
for (int i = 0; i < cands.size(); ++i) {
int x = flip(cands[i], cands[i == 0]);
bool flg = 1;
for (int j = 0; j < cands.size(); ++j) {
if (i ^ j) {
flg &= x == flip(cands[i], cands[j]);
}
}
if (flg) {
res[cands[i]] = x;
swap(cands[i], cands.back());
break;
}
}
cands.pop_back();
};
for (int i = 3; i < 2 * N; ++i) {
cands.push_back(i);
extract();
}
if (N > 1) {
extract();
}
res[cands[0]] = res[cands[1]] = flip(cands[0], cands[1]);
for (int i = 0; i < 2 * N; ++i) {
for (int j = i + 1; j < 2 * N; ++j) {
if (res[i] == res[j]) {
Answer(i, j, res[i]);
}
}
}
}
Compilation message (stderr)
memory2.cpp: In lambda function:
memory2.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | for (int i = 0; i < cands.size(); ++i) {
| ~~^~~~~~~~~~~~~~
memory2.cpp:20:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for (int j = 0; j < cands.size(); ++j) {
| ~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |