bzoj 3563: DZY Loves Chinese
来源:互联网 发布:上海地铁免费查询软件 编辑:程序博客网 时间:2024/06/05 01:55
题解
这题很搞笑。。
想了一下发现,这个强制在线可以帮我出答案
难点就是怎么找到每个询问是什么
问了下做过的人,没有行末回车
于是就可以很愉快地乱搞了,具体看代码。。
然后最后一次暴力搞就行了
#include<cstdio>#include<cstring>const int M=500000;int n,m,q;char ss[1005];int ans=0;//之前有多少个bool ok[M];int f[M];int X[M],Y[M];int find (int x){ return f[x]==x?f[x]:f[x]=find(f[x]);}int main(){ scanf("%d%d",&n,&m); for (int u=1;u<=m;u++) scanf("%d%d",&X[u],&Y[u]); scanf("%d\n",&q); for (int u=1;u<=q;u++) { gets(ss); int len=strlen(ss); int lalal=0; int now=0; while (ss[now]>='0'&&ss[now]<='9') {lalal=lalal*10+ss[now]-'0';now++;} int cnt=0;//有多少个 for (int i=now;i<len;i++)//直接扫过去 { if (ss[i]>='0'&&ss[i]<='9') { cnt++; while (ss[i]>='0'&&ss[i]<='9') i++; } } int shen=(lalal^cnt); if (u!=1) { if (shen==ans) printf("Disconnected\n"); else printf("Connected\n"); } ans=shen; } int len=strlen(ss); int lalal=0,now=0; while (ss[now]>='0'&&ss[now]<='9') {lalal=lalal*10+ss[now]-'0';now++;} memset(ok,true,sizeof(ok)); for (int i=now;i<len;i++)//直接扫过去 { if (ss[i]>='0'&&ss[i]<='9') { int lalal=0; while (ss[i]>='0'&&ss[i]<='9') { lalal=lalal*10+(ss[i]-'0'); i++; } ok[lalal^ans]=false; } } for (int u=1;u<=n;u++) f[u]=u; for (int u=1;u<=m;u++) { if (ok[u]) { int x=find(X[u]),y=find(Y[u]); f[x]=y; } } bool tf=true; int x=find(1); for (int u=2;u<=n;u++) if (x!=find(u)) { tf=false; break; } if (!tf) printf("Disconnected\n"); else printf("Connected\n"); return 0;}
阅读全文
0 0
- bzoj 3563: DZY Loves Chinese
- bzoj 3563: DZY Loves Chinese
- bzoj 3563: DZY Loves Chinese
- BZOJ 3563 DZY Loves Chinese / BZOJ 3569 DZY Loves Chinese II 随机化+高斯消元解异或方程组
- BZOJ 3569 DZY Loves Chinese(BZOJ 3563) II 线性基
- BZOJ 3563 DZY Loves Chinese 并查集
- [bzoj 3563&3569]DZY Loves Chinese I&II
- [乱搞 暴力 并查集] BZOJ 3563 DZY Loves Chinese
- bzoj 3563: DZY Loves Chinese 并查集+乱搞
- BZOJ 3563 DZY Loves Chinese(线性基)
- BZOJ 3569 DZY Loves Chinese II 高斯消元
- bzoj 3569: DZY Loves Chinese II
- BZOJ 3569: DZY Loves Chinese II
- bzoj 3569: DZY Loves Chinese II (线性基)
- BZOJ 3569: DZY Loves Chinese II 线性基 随机化
- BZOJ 3569 DZY Loves Chinese II(线性基)
- 3237: [Ahoi2013]连通图/3563: DZY Loves Chinese/3569: DZY Loves Chinese II 线性基+随机化
- BZOJ3563/3569 DZY Loves Chinese II/DZY Loves Chinese
- java web端调用tensorflow模型
- Hashedcubes: 对于大数据的简洁,低存耗,实时的可视探索
- 通过可视化数据分析提升测试质量
- 软考分页存储求物理地址公式
- 路由侧边栏
- bzoj 3563: DZY Loves Chinese
- 30 个最好的数据可视化工具推荐
- input file multiple 配合springmvc实现多文件上传
- 一图看懂:2017年中国自媒体从业人员生存状况
- Impala修改/删除/清空表操作
- 五步教你设计成功而有价值的数据可视化
- Java泛型详解
- 如何将数据可视化技术应用于广告投放?
- JavaScript字符串操作