poj 2345 Central heating
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 678 | Accepted: 310 |
Description
Your task is to determine who of the technicians is to get an instruction "to turn on the heating" in order to heat all the Ural State University. Note that there are N technicians and N valves at the University (1 <= N <= 250).
Input
Output
Sample Input
4
1 2 -1
2 3 4 -1
2 -1
4 -1
Sample Output
1 2 3
Source
/*
* @Author: Lyucheng
* @Date: 2017-08-09 16:37:47
* @Last Modified by: lyuc
* @Last Modified time: 2017-08-14 11:31:17
*/ /*
题意:有n个窗口,有n个师傅,每个师傅可以管理很多窗口,可以重复的,给一个师傅下命令,这个师傅会管理他所有的
窗口,如果是关闭的就打开,如果是打开的就关闭,现在想让所有的窗口打开,问你怎么下命令 思路:将每个师傅管理的窗口转化成01序列,末尾加0,表示方程的结果,然后凑成矩阵,高斯消元解方程,消元的时候
变成异或
*/ #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h> #define MAXN 255 using namespace std; int n;
int cur;
int a[MAXN][MAXN];//增广矩阵
int x[MAXN];//解集 void Gauss(){
for(int i=;i<n;i++){
int col=-;
for(int j=i;j<n;j++){//找到第一个不为零的行
if(a[j][i]){
col=j;
break;
}
}
for(int j=i;j<=n;j++){
swap(a[i][j],a[col][j]);
}
for(int j=i+;j<n;j++){
if(a[j][i]!=){
for(int k=i;k<=n;k++){
a[j][k]^= a[i][k];
}
}
}
}
for (int i=n-;i>=;--i){
x[i] = a[i][n];
for (int j=i-;j>=;--j){
a[j][n]^=(x[i]&a[j][i]);
}
}
} inline void init(){
memset(a,,sizeof a);
memset(x,,sizeof x);
} int main(){
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
while(scanf("%d",&n)!=EOF){
init();
for(int i=;i<n;i++){
while(scanf("%d",&cur)&&cur!=-){
a[cur-][i]=;
}
a[i][n]=;
} Gauss();
bool flag=true;
for (int i=;i<n;i++){
if(x[i]){
if(flag==true){
flag=false;
printf("%d",i+);
}else{
printf(" %d",i+);
}
}
}
printf("\n");
}
return ;
}
poj 2345 Central heating的更多相关文章
- [高斯消元] POJ 2345 Central heating
Central heating Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 614 Accepted: 286 Des ...
- POJ 2345 Central heating(高斯消元)
[题目链接] http://poj.org/problem?id=2345 [题目大意] 给出n个开关和n个人,每个人可以控制一些开关,现在所有的开关都是关着的 一个指令可以让一个人掰动所有属于他控制 ...
- js地址下拉列表中全职工作
/******************************************************************* *输出全国各省辖市下拉列表项writeCitys() *输出企 ...
- 每日英语:Air Pollution From Coal Use Cuts Lifespans in China, Study Shows
Air pollution from coal combustion likely cut life expectancy in parts of China by more than five ye ...
- words2
餐具:coffee pot 咖啡壶coffee cup 咖啡杯paper towel 纸巾napkin 餐巾table cloth 桌布tea -pot 茶壶tea set 茶具tea tray 茶盘 ...
- poj 2732 Countdown(East Central North America 2005)
题意:建一个家庭树,找出有第d代子孙的名字,按照要求的第d代子孙的数从大到小输出三个人名,如果有一样大小子孙数的,就按字母序从小到大将同等大小的都输出,如果小于三个人的就全输出. 题目链接:http: ...
- POJ 1240 Pre-Post-erous! && East Central North America 2002 (由前序后序遍历序列推出M叉树的种类)
题目链接:http://poj.org/problem?id=1240 本文链接:http://www.cnblogs.com/Ash-ly/p/5482520.html 题意: 通过一棵二叉树的中序 ...
- POJ 1240 Pre-Post-erous! && East Central North America 2002 (由前序后序遍历序列推出M叉树的种类)
题目链接 问题描述 : We are all familiar with pre-order, in-order and post-order traversals of binary trees. ...
- poj 1008:Maya Calendar(模拟题,玛雅日历转换)
Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 64795 Accepted: 19978 D ...
随机推荐
- String类的一些转换功能(6)
1:把字符串转换成字节数组 getBytes() 如: String s = "你好啊!" //编码 byte [] arr = s.getBytes();//这里默认编码格式是g ...
- GCD之after
先介绍下C中的modf函数 函数名:modf 头文件:<math.h> 函数原型:double modf(double x, double *ipart) 函数用途:分解x,以得到x的整数 ...
- Python数据分析(二): Numpy技巧 (3/4)
numpy.pandas.matplotlib(+seaborn)是python数据分析/机器学习的基本工具. numpy的内容特别丰富,我这里只能介绍一下比较常见的方法和属性. 昨天晚上发了第一 ...
- Average of Levels in Binary Tree
Given a non-empty binary tree, return the average value of the nodes on each level in the form of an ...
- Java面向对象 集合(下)
Java面向对象 集合(下) 知识概要: (1)Map集合的体系结构 (2)Map集合的方法 (3)HashMap TreeMap (4)集合框架中的常用工具类 ( ...
- zabbix基本操作
zabbix基本操作 ---- 2016年终总结 二 包括的内容: 添加主机 查看监控数据 添加监控项 创建触发器 创建模版 添加报警 添加媒介 添加主机 进入页面 点击Configuration(大 ...
- jquery系列教程4-事件操作全解
点击打开: jquery系列教程1-选择器全解 jquery系列教程2-style样式操作全解 jquery系列教程3-DOM操作全解 jquery系列教程4-事件操作全解 jquery系列教程5-动 ...
- DevOps之域名
唠叨话 关于德语噢屁事的知识点,仅提供精华汇总,具体知识点细节,参考教程网址,如需帮助,请留言. 域名系统DNS(Domain Name System) 关于域名,知识与技能的层次(知道.理解.运用) ...
- IOS应用FFMPEG库
1.引用资源 build-ffmpeg ffmpeg库生成 -sh开源地址: https://gist.github.com/m1entus/6983547 iFrameExtractor ffmp ...
- MIRO做发票校验时实现替代功能的多种方式
http://blog.sina.com.cn/s/blog_3f2c03e30100ngje.html MIRO做发票校验时,如果需要对产生的会计凭证做某些字段的替代,可有多种方法. 1.GGB1替 ...