[51nod 1851]俄罗斯方块
来源:互联网 发布:阿里云和腾讯云的市场 编辑:程序博客网 时间:2024/06/05 00:07
题目描述
给一个黑白图,每次能将某些区域的格子黑白反转,至于某些区域的意思嘛,就是俄罗斯方块形状的区域咯(可水平翻转、上下翻转、旋转)
求能否将图变成全白
结论
51nod的题解写得比较好。
这里懒得写了。
#include<cstdio>#include<algorithm>#define fo(i,a,b) for(i=a;i<=b;i++)using namespace std;int s[10000000+10];int i,j,k,l,t,n,m,tot,ca;bool czy;char ch;char get(){ char ch=getchar(); while (ch<'0'||ch>'1') ch=getchar(); return ch;}int main(){ scanf("%d",&ca); while (ca--){ scanf("%d%d",&n,&m); if (n>m) swap(n,m); t=tot=0; fo(i,1,n) fo(j,1,m) s[++tot]=get()-'0',t+=s[tot]; if (n>=2&&m>=3){ if (t%2==0) printf("Yes\n");else printf("No\n"); //continue; } else if (n==2&&m==2){ if (t==0||t==4) printf("Yes\n");else printf("No\n"); //continue; } else{ fo(i,1,m-3) if (s[i]){ s[i]^=1; s[i+1]^=1; s[i+2]^=1; s[i+3]^=1; } czy=1; fo(i,m-2,m) if (s[i]){ czy=0; break; } if (czy) printf("Yes\n");else printf("No\n"); } }}
阅读全文
0 0
- [51nod 1851]俄罗斯方块
- 51 nod 1851 俄罗斯方块
- 51nod 俄罗斯方块(找规律(构造))
- 俄罗斯方块
- 俄罗斯方块
- 俄罗斯方块!
- 俄罗斯方块
- 俄罗斯方块
- 俄罗斯方块
- 俄罗斯方块
- 俄罗斯方块
- 俄罗斯方块
- 俄罗斯方块
- 俄罗斯方块
- 俄罗斯方块
- 俄罗斯方块
- 俄罗斯方块
- 俄罗斯方块
- Tarjan 算法超级详解
- ArrayList的用法
- KMP算法
- 什么是构造和析构方法?功能是?
- 国内某著名IT公司编程测验: 以数组内的三个下标四等分一个数组
- [51nod 1851]俄罗斯方块
- ArrayList的使用
- ArrayList的用法
- 清理Linux系统垃圾文件操作方法
- Jinixin Speech
- recyleviewdemo
- String 字符串的反转
- POJ3421 X-factor Chains【分解质因子+组合数学】
- 对数指数变换