while (t --) { scanf("%d %d %d", &n, &a, &b); if (abs(a - b) > 1) noans(); if (a == b) { if ((a + 1) * 2 > n) noans(); int st1 = a + 2, st2 = a + 1; for (int j = n, t = 0; t <= a; t ++, j -= 2) ans[j] = st1 ++, ans[j - 1] = st2 --; for (int i = 1; i <= n - ((a + 1) << 1); i ++) ans[i] = i; for (int i = n - ((a + 1) << 1) + 1; i <= n; ++ i) ans[i] += n - ((a + 1) << 1); } elseif (a == b + 1) { if (a * 2 + 1 > n) noans(); int st1 = a + 1, st2 = a + 2; for (int j = n, t = 0; t <= b; t ++, j -= 2) ans[j] = st1 --, ans[j - 1] = st2 ++; ans[n - ((b + 1) << 1)] = 1; for (int i = 1; i <= n - (a << 1) - 1; i ++) ans[i] = i; for (int i = n - (a << 1); i <= n; ++ i) ans[i] += n - (a << 1) - 1; } elseif (a == b - 1) { if (b * 2 + 1 > n) noans(); int st1 = b * 2 + 1, st2 = 1; for (int j = 1, t = 0; t <= a; ++ t, j += 2) ans[j] = st1 --, ans[j + 1] = st2 ++; ans[b * 2 + 1] = b + 1; for (int i = (b + 1) << 1; i <= n; ++ i) ans[i] = i; } for (int i = 1; i <= n; ++ i) printf("%d ", ans[i]); puts(""); }
看到 C 题,感觉是一个二维偏序问题,和 Dyd 讨论了一会,发现可以先排序,后一个向前一个连一条边表示可以战胜,是一个 Tarjan 可以快速搞完,就可以了。但是确实如果是我自己想的话,大概率是想不出来的。