poj2965The Pilots Brothers' refrigerator
来源:互联网 发布:阿里云学生主机 编辑:程序博客网 时间:2024/05/10 16:42
http://poj.org/problem?id=2965
按下‘+’按钮,再把‘+’号所在行和列的按钮全部按一遍,这样就把‘+’变成‘-’而不改变其他任何按钮。
mark[][]初始化全置0,按过的地方改为1,再按一次又变为0,抵消上一次操作。mark[][]为1的位置,按过了奇数次,为0的位置按过了偶数次(跟没按一样,所以不需要动它)。
最终mark[][]为1的位置即为所求。
#include <stdio.h>#include <string.h>int mark[4][4];char s[4][4];int main(){ int i,j,k,ci[16],cj[16],count=0; memset(mark,0,sizeof(mark));for(i = 0;i < 4;i++)//输入测试样例scanf("%s",s[i]); for(i = 0;i < 4;i++) for(j = 0;j < 4;j++) { char c = s[i][j]; if(c == '+') { mark[i][j] = !mark[i][j];//'+'本身取反 for(k = 0;k < 4;k++) { mark[i][k] = !mark[i][k];//'+'号所在行取反 mark[k][j] = !mark[k][j];//'+'号所在列取反 } } } for(i = 0;i < 4;i++) for(j = 0;j < 4;j++) if(mark[i][j] == 1) { ci[count] = i + 1; cj[count] = j + 1; count++; } printf("%d\n",count); for(i = 0;i<count;i++) printf("%d %d\n",ci[i],cj[i]); return 0;}
0 0
- poj2965The Pilots Brothers' refrigerator
- poj2965The Pilots Brothers' refrigerator
- POJ2965The Pilots Brothers' refrigerator
- poj2965The Pilots Brothers' refrigerator DFS+枚举
- The Pilots Brothers' refrigerator
- The Pilots Brothers' refrigerator
- POJ2965_The Pilots Brothers' refrigerator
- The Pilots Brothers' refrigerator
- The Pilots Brothers' refrigerator
- The Pilots Brothers' refrigerator
- The Pilots Brothers' refrigerator
- The Pilots Brothers' refrigerator
- The Pilots Brothers' refrigerator
- The Pilots Brothers' refrigerator
- The Pilots Brothers' refrigerator
- PKU2965 The Pilots Brothers' refrigerator
- POJ2965 The Pilots Brothers' refrigerator
- POJ2965----The Pilots Brothers' refrigerator
- Java transient关键字
- avalon学习笔记(1) avalon+oniui+ajax实现smartgrid的无刷新分页
- Scroller的fling方法详解
- jQuery插件开发精品教程,让你的jQuery提升一个台阶
- 何时执行ServletRequestAware和ServletRequestAware相关操作
- poj2965The Pilots Brothers' refrigerator
- Centos6.5安装docker
- centos zookeeper 实战之集群搭建
- 【c#操作office】--OleDbDataAdapter 与OleDbDataReader方式读取excel,并转换为datatable
- hdu1166(线段数,节点更新)
- Hibernate与 MyBatis的比较
- HDOJ/HDU 1113 Word Amalgamation(字典顺序~Map)
- [dhtmlxGantt(甘特图)开发手册]第四篇——撤销/重做、提示消息、加载任务
- 认识整机托管和虚拟主机