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 ...
随机推荐
- 【SQL】- 基础知识梳理(六) - 游标
游标的概念 结果集,结果集就是select查询之后返回的所有行数据的集合. 游标(Cursor): 是处理数据的一种方法. 它可以定位到结果集中的某一行,对数据进行读写. 也可以移动游标定位到你需要的 ...
- 关于Android WebView上传文件的解决方案
我们在开发需求的时候,难免会接入一下第三方的H5页面,有些H5页面是具有上传照片的功能,Android 中的 WebView是不能直接打开文件选择弹框的 接下来我讲简单提供一下解决方案,先说一下思路 ...
- Ubuntu16.04安装piwik3.0.1
1.安装PHP环境 sudo apt-get install php7.0-fpm 2.下载piwik3.0.1 https://piwik.org/download/ 下载后解压到/var/ww ...
- 在vue中let var 和const 区别
let和const 使用方法: (1).有没有感觉到在 javascript 使用var会发生变量提升,即脚本开始运行时, 变量已经存在了,但是没有值,所以会输出undefined. 而 ...
- 用postal.js在AngularJS中实现订阅发布消息
点击查看AngularJS系列目录 用postal.js在AngularJS中实现event bus 用postal.js在AngularJS中实现event bus 理想状态下,在一个Angular ...
- 【POJ】1067 取石子游戏(博弈论)
Description 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两堆中同时取走相同数量的石子.最后 ...
- 童话故事 --- 通信协议之 HDLC 浅析
高飞狗: "高飞的白鹭浮水的鹅,唐诗里有画-" 布鲁托: "高飞狗,又在做你的高飞梦哪!" 高飞狗: "哈罗,布鲁托,这几天好郁闷呐!" 布 ...
- 表空间tablespace,数据文件datafiles,和控制文件control files介绍
https://docs.oracle.com/cd/B19306_01/server.102/b14220/physical.htm#i5919 本文系翻译 表空间tablespace,数据文件da ...
- window开启remote desktop服务
确定自己的PC支持远程桌面 1 先确定被遥控的电脑的系统必须是Professional或Enterprise以上版本,家庭版不支持远程桌面.以Win8.1(7和8同理)为例,依次打开控制面板→系统 ...
- zoj1383 zoj3418 二进制 基础
传送门 题目大意:从末位到首位输出所在位置的值是1的位置. 可以用除----> num>>1 或减----> -(n^(-n)) #include<cstdio> ...