CF1342B

· · 题解

题解思路:

我们要构造一个 01s,使得 s 的长度是 \le 2\cdot t,使得 k 最小。

那么当 $t$ 是全零或者全一的,那么直接输出 $t$ 就可以了。 否则输出 $0101...01$,因为 $k=2$,最小的了。 ```cpp #include <iostream> using namespace std; int main() { int T; scanf("%d", &T); while (T--) { string s; cin >> s; bool ok = false, ok2 = false; for (auto x : s) { if (x == '1') ok = true; else ok2 = true; } if (!ok || !ok2)//全0或者全1 { cout << s << endl; continue; } for (int i = 0; i < s.size(); ++i)//输出01 printf("01"); putchar('\n'); } return 0; } ```