#include "Memory2_lib.h"
#include <string.h>
const int N = 50;
int ei[N][2], eo[N];
void append(int a, int i) {
ei[a][eo[a]++] = i;
}
int qu[N * 2];
void Solve(int t, int n) {
t = t;
memset(eo, 0, n * sizeof *eo);
int cnt = 0;
for (int i = 0; i < n * 2; i++)
qu[cnt++] = i;
while (cnt)
if (cnt == 1) {
int i = qu[--cnt];
for (int a = 0; a < n; a++)
if (eo[a] == 1) {
append(a, i);
break;
}
} else if (cnt == 2) {
int i = qu[--cnt], j = qu[--cnt];
bool done = false;
for (int a = 0; a < n; a++)
if (eo[a] == 0) {
append(a, i), append(a, j);
done = true;
break;
}
if (done)
continue;
int a = -1, b = -1;
for (int c = 0; c < n; c++)
if (eo[c] == 1) {
if (a == -1)
a = c;
else
b = c;
}
if (Flip(ei[a][0], i) == a && Flip(ei[b][0], j) == b)
append(a, i), append(b, j);
else
append(a, j), append(b, i);
} else {
int i = qu[--cnt], j = qu[--cnt], k = qu[--cnt];
int a = Flip(i, j), b = Flip(j, k), c = Flip(k, i);
if (a != b || b != c) {
if (c == a)
append(a, i), qu[cnt++] = j, qu[cnt++] = k;
else if (a == b)
append(b, j), qu[cnt++] = k, qu[cnt++] = i;
else
append(c, k), qu[cnt++] = i, qu[cnt++] = j;
} else {
while (cnt) {
int l = qu[--cnt], d = Flip(l, i), e = Flip(l, j), f = Flip(l, k);
if (d != e || e != f) {
if (d == e)
append(d, i), append(d, j), qu[cnt++] = k;
else if (e == f)
append(e, j), append(e, k), qu[cnt++] = i;
else
append(f, k), append(f, i), qu[cnt++] = j;
qu[cnt++] = l;
break;
} else
append(d, l);
}
if (cnt == 0) {
int a = -1, b = -1;
for (int c = 0; c < n; c++)
if (eo[c] == 0)
a = c;
else if (eo[c] == 1)
b = c;
if (Flip(ei[b][0], i) == b)
append(a, j), append(a, k), append(b, i);
else if (Flip(ei[b][0], j) == b)
append(a, k), append(a, i), append(b, j);
else
append(a, i), append(a, j), append(b, k);
}
}
}
for (int a = 0; a < n; a++)
Answer(ei[a][0], ei[a][1], a);
}
Compilation message
memory2.c:6:5: error: variably modified 'ei' at file scope
6 | int ei[N][2], eo[N];
| ^~
memory2.c:6:15: error: variably modified 'eo' at file scope
6 | int ei[N][2], eo[N];
| ^~
memory2.c:12:5: error: variably modified 'qu' at file scope
12 | int qu[N * 2];
| ^~
memory2.c: In function 'Solve':
memory2.c:30:4: error: unknown type name 'bool'
30 | bool done = false;
| ^~~~
memory2.c:30:16: error: 'false' undeclared (first use in this function)
30 | bool done = false;
| ^~~~~
memory2.c:30:16: note: each undeclared identifier is reported only once for each function it appears in
memory2.c:34:13: error: 'true' undeclared (first use in this function)
34 | done = true;
| ^~~~