From 232c333ec53e953e015114d2f636dcf034782f8e Mon Sep 17 00:00:00 2001 From: hanyixuanten <105723997+hanyixuanten@users.noreply.github.com> Date: Fri, 14 Aug 2026 19:37:03 +0800 Subject: [PATCH] new file: P10449.cpp --- P10449.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 P10449.cpp diff --git a/P10449.cpp b/P10449.cpp new file mode 100644 index 0000000..fff129f --- /dev/null +++ b/P10449.cpp @@ -0,0 +1,74 @@ +// 95 +#include +using namespace std; + +int t; +int a[6]; + +int main() +{ + scanf("%d", &t); + while (t--) + { + for (int i = 0; i < 5; i++) + { + a[i] = 0; + for (int j = 0; j < 5;) + { + int c = getchar(); + if (c == '0' || c == '1') + { + if (c == '0') + a[i] |= 1 << (4 - j); + ++j; + } + } + } + int ans = 7; + for (int fline = 0; fline < 32; ++fline) + { + int noww[5]; + for (int i = 0; i < 5; ++i) + noww[i] = a[i]; + int pp[5] = {0}; + pp[0] = fline; + noww[0] ^= pp[0]; + noww[0] ^= (pp[0] << 1) & 0x1F; + noww[0] ^= (pp[0] >> 1); + noww[1] ^= pp[0]; + for (int r = 1; r < 5; ++r) + { + pp[r] = noww[r - 1]; + noww[r] ^= pp[r]; + noww[r] ^= (pp[r] << 1) & 0x1F; + noww[r] ^= (pp[r] >> 1); + noww[r - 1] ^= pp[r]; + if (r < 4) + noww[r + 1] ^= pp[r]; + } + + bool flag = true; + for (int i = 0; i < 5; ++i) + { + if (noww[i] != 0) + { + flag = false; + break; + } + } + if (flag) + { + int cnt = 0; + for (int i = 0; i < 5; ++i) + cnt += __builtin_popcount(pp[i]); + if (cnt < ans) + ans = cnt; + } + } + if (ans > 6) + printf("-1\n"); + else + printf("%d\n", ans); + } + return 0; +} \ No newline at end of file