P3857 [TJOI2008]彩灯 题解
把 O
看成了 0
调了一上午。
我们考虑用线性基来搞,然后有几个 ,答案就是 。
/* Work by: TLE_Automation */ #include<cmath> #include<queue> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define LL long long #define int long long using namespace std; const int N = 1e6 + 10; const int MAXN = 2e5 + 10; inline char readchar() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } inline int read() { #define readchar getchar int res = 0, f = 0; char ch = readchar(); for (; !isdigit(ch); ch = readchar()) if (ch == '-') f = 1; for (; isdigit(ch); ch = readchar()) res = (res << 1) + (res << 3) + (ch ^ '0'); return f ? -res : res; } inline void print(int x) { if (x < 0 ) putchar('-'), x = -x; if (x > 9 ) print(x / 10); putchar(x % 10 + '0'); } int p[100], ans; void Insert(int x) { for (int i = 63; i >= 0; i--) { if (x & (1ll << i)) { if (p[i]) x ^= p[i]; else { p[i] = x; break; } } } } char s[MAXN]; signed main() { int n = read(), m = read(); for (int i = 1; i <= m; ++i) { scanf("%s", s + 1); int x = 0; for (int j = 1; j <= n; ++j) if (s[j] == 'O') x |= (1ll << (j - 1)); Insert(x); } int cnt = 0; for (int i = 60; i >= 0; --i) if (p[i]) cnt++; printf("%lld\n", (1ll << cnt) % mod); return 0; }
本文作者:TLE_Automation
本文链接:https://www.cnblogs.com/tttttttle/p/16297246.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现