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 ...
随机推荐
- Rendering Problems Failed to load platform rendering library 为何打开布局页面时手机预览页面显示不出来?
看到图片右上角的 android图标没有?把它改为低版本的就可以了,如我的是21就可以了.原因我想是因为sdk版本更新了不兼容导致的吧.
- 西邮linux兴趣小组2014纳新免试题(二)
[第二关] 题目 http://round2.sinaapp.com/ 分析 打开后,戳进去发现一句名言,然后下一戳的url提示. 在网页源码中得到Page1024提示,于是写一个脚本 #!/bin/ ...
- js 各种循环的区别与用法(for in,forEach,for of)
1,forEach循环 不能跳过或者终止循环 const a = ["a","ss","cc"] a.dd="11" ...
- 【Linux笔记(001) 】-- centos7 系统目录结构与文件
一.目录结构与用途: /boot:系统引导文件.内核 /bin:用户的基本命令 /dev:设备文件 /etc:配置文件 /home:用户目录 /root:root用户目录 /sbin:管理类的基本命令 ...
- 再起航,我的学习笔记之JavaScript设计模式27(链模式)
链模式 概念介绍 链模式(Operatc of Responsibility): 通过在对象方法中将当前对象返回,实现对同一个对象多个方法的链式调用.从而简化对该对象的多个方法的多次调用时,对该对象的 ...
- 一个“.java”文件中是否可以包含多个类(不是内部类)?有什么限制?
可以,若这个类的修饰符是public则,其类名须与文件名相同.
- OpenVPN server端配置文件详细说明(转)
本文将介绍如何配置OpenVPN服务器端的配置文件.在Windows系统中,该配置文件一般叫做server.ovpn:在Linux/BSD系统中,该配置文件一般叫做server.conf.虽然配置文件 ...
- CentOS 7搭建LAMP环境(二)
前面已经讲过了CentOS 7下LAMP环境的配置过程,一台简单的WEB服务器已搭建完成,但后期在网站部署的过程中也许会碰到各种各样头疼的问题.下面我们来讲讲怎么解决这些问题,以及如何高效地管理服务器 ...
- zoj 1526 Big Number 数学
Big Number Time Limit: 10 Seconds Memory Limit: 32768 KB In many applications very large intege ...
- wpf 制作必输项的*标记
直接引用帮助文档上的话吧,以免下次忘记! AdornedElementPlaceholder 类 .NET Framework 3.5 其他版本 此主题尚未评级 - 评价此主题 更新:20 ...