# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
39783 |
2018-01-18T13:51:32 Z |
aome |
None (JOI16_memory2) |
C++14 |
|
1 ms |
2068 KB |
#include <bits/stdc++.h>
#include "Memory2_lib.h"
using namespace std;
const int N = 105;
int res[N];
int f[N][N];
int cnt[N];
bool vis[N];
vector<int> v;
void Solve(int T, int n) {
memset(f, -1, sizeof f);
memset(res, -1, sizeof res);
if (n == 1) {
Answer(0, 1, 0); return;
}
for (int i = 0; i < 3; ++i) v.push_back(i);
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < i; ++j) {
f[i][j] = f[j][i] = Flip(i, j);
}
}
for (int i = 3; i < 2 * n; ++i) {
for (int j = 0; j < 3; ++j) {
f[i][v[j]] = f[v[j]][i] = Flip(i, v[j]);
}
v.push_back(i);
for (int j = 0; j < 4; ++j) {
int tmp = -1;
bool flag = 0;
for (int k = 0; k < 4; ++k) {
if (k == j) continue;
if (tmp == -1) tmp = f[v[j]][v[k]];
if (tmp != f[v[j]][v[k]]) flag = 1;
}
if (!flag) {
res[v[j]] = tmp;
vector<int> _v = v; v.clear();
for (int k = 0; k < 4; ++k) {
if (k == j) continue; v.push_back(_v[k]);
}
break;
}
}
}
// for (int i = 0; i < n * 2; ++i) cout << res[i] << ' '; cout << '\n';
for (int i = 0; i < n * 2; ++i) {
if (res[i] == -1) continue;
for (int j = i + 1; j < n * 2; ++j) {
if (res[j] == -1) continue;
if (res[i] == res[j]) Answer(i, j, res[j]), vis[res[j]] = 1;
}
}
int pos = -1;
for (int i = 0; i < n * 2; ++i) {
if (res[i] != -1 && !vis[res[i]]) pos = i;
}
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < i; ++j) {
if (f[v[i]][v[j]] != res[pos]) {
Answer(v[i], v[j], f[v[i]][v[j]]);
for (int k = 0; k < 3; ++k) {
if (k != i && k != j) {
Answer(pos, v[k], res[pos]);
}
}
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2068 KB |
Output is correct |
2 |
Correct |
0 ms |
2068 KB |
Output is correct |
3 |
Correct |
0 ms |
2068 KB |
Output is correct |
4 |
Correct |
0 ms |
2068 KB |
Output is correct |
5 |
Correct |
0 ms |
2068 KB |
Output is correct |
6 |
Correct |
0 ms |
2068 KB |
Output is correct |
7 |
Correct |
0 ms |
2068 KB |
Output is correct |
8 |
Correct |
0 ms |
2068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2068 KB |
Output is correct |
2 |
Correct |
0 ms |
2068 KB |
Output is correct |
3 |
Correct |
0 ms |
2068 KB |
Output is correct |
4 |
Correct |
0 ms |
2068 KB |
Output is correct |
5 |
Correct |
0 ms |
2068 KB |
Output is correct |
6 |
Correct |
0 ms |
2068 KB |
Output is correct |
7 |
Correct |
0 ms |
2068 KB |
Output is correct |
8 |
Correct |
0 ms |
2068 KB |
Output is correct |
9 |
Correct |
0 ms |
2068 KB |
Output is correct |
10 |
Correct |
0 ms |
2068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2068 KB |
Output is correct |
2 |
Correct |
0 ms |
2068 KB |
Output is correct |
3 |
Correct |
0 ms |
2068 KB |
Output is correct |
4 |
Correct |
0 ms |
2068 KB |
Output is correct |
5 |
Correct |
0 ms |
2068 KB |
Output is correct |
6 |
Correct |
0 ms |
2068 KB |
Output is correct |
7 |
Correct |
0 ms |
2068 KB |
Output is correct |
8 |
Correct |
0 ms |
2068 KB |
Output is correct |
9 |
Correct |
0 ms |
2068 KB |
Output is correct |
10 |
Correct |
0 ms |
2068 KB |
Output is correct |