FZU 1704 Turn off the light
来源:互联网 发布:软件系统设计文档 编辑:程序博客网 时间:2024/06/09 06:19
Problem Description
There are N lights and M switches in Peter’s bedroom. Every switch controls some lights among all. When press the switch, these lights will change their statuses (the lighting ones will be turn off, while the shutting one will be turn on.) Now some lights are lighting. Peter would like to know that under the premises of not pressing one switch twice, how many methods he could turn all the lights off. There is always at least one way to turn all the lights off.
Input
Output
For each test case, print a line contains the answer.
Sample Input
1
2 3
1 1
2 1 2
1 1
1 2
Sample Output
2
#include<iostream>#include<cstring>#include<cstdio>using namespace std;int a[110][110],b[100];int main(){int t;scanf("%d",&t);while(t--){int n,m,i,j,k;memset(a,0,sizeof(a));scanf("%d%d",&n,&m);for(i=0;i<n;i++) scanf("%d",&a[i][m]);for(i=0;i<m;i++){int d,x;scanf("%d",&d);while(d--){scanf("%d",&x);a[x-1][i]=1;}}int res=0,r=0;for(i=0;i<m&&r<n;i++){for(j=r;j<n;j++){if(a[j][i]>0){if(j!=r)for(k=i;k<=m;k++) swap(a[j][k],a[r][k]);break;}}if(a[r][i]==0){res++;continue;}for(j=0;j<n;j++){if(j!=r&&a[j][i]!=0){for(k=i;k<=m;k++) a[j][k]^=a[r][k];}}r++;}int len=1,y;b[0]=1;for(i=0;i<m-r;i++){y=0;for(j=0;j<len;j++){b[j]=b[j]*2+y;y=b[j]/10;b[j]%=10;}if(y!=0){b[len]=y;len++;}}for(i=len-1;i>=0;i--) printf("%d",b[i]);printf("\n");}return 0;}
0 0
- FZU 1704 Turn off the light
- FZU 1704 Turn off the light
- FZUOJ 1704 Turn off the light (高斯消元+大数高精度)
- How to turn off the Javadoc hover
- Turn off the rightmost set bit
- android disable the Auto light off
- 关灯看视频(Turn Off the Lights)
- Educational Codeforces Round 29 E. Turn Off The TV
- turn on/off webcache
- Turn on/off monitor
- turn off x-window
- turn on/off xwindow
- The Byrds - Turn! Turn! Turn!
- Light on or off
- switch off light
- Turn off Windows10 automatic updates
- Turn off cache of Thumdbs.db to prevent the move blocking from it in automation
- Outlook 2007 - Cannot turn off the reminder. You may be reminded again. Cannot locate recurrnence in
- C#屏幕拷贝源码
- ubuntu 只显示当前路径的目录
- ~超时--拓扑排序
- linux学习笔记(gentoo)
- Spring中使用proxool的配置+【转】proxool.xml配置属性说明
- FZU 1704 Turn off the light
- 整合structs2和spring前提下使用proxool
- 关于Usb直接拔出导致的进程崩溃问题
- Centos6.4安装JDK
- ejs 无法解析标签
- CentOS6.4下Mysql数据库的安装与配置
- linux sudo和su区别
- T-SQL获取标识值
- 使用.udl快速测试与数据库的连接并得到连接字符串(OLEDB、ADO)