博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ural 1042 Central Heating
阅读量:7225 次
发布时间:2019-06-29

本文共 2389 字,大约阅读时间需要 7 分钟。

Winter has come, but at the Ural State University heating is not turned on yet. There’s one little problem: the University is heated only if all of the valves are opened. There are some technicians at the University. Each of them is responsible for one or more valves. There may be several technicians responsible for the same valve. When a technician gets an instruction to turn on the heating he goes round all of his valves and turns them. It means that if a valve was opened then he closes it, and if it was closed then he opens it. It is well known that every technician earns his money not in vain so it’s impossible to replace any technician by any combination of other technicians.

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 (1N250).

Input

The first line of the input contains the number N. The next N lines contain lists of the valves in charge of each of the technicians. It means that the line number i+1 contains numbers of the valves that the i-th technician is responsible for. Each list of valves is followed by 1.

Output

An output should contain a list of technicians’ numbers sorted in ascending order. If several lists are possible, you should send to an output the shortest one. If it’s impossible to turn on the heating at the University, you should write “No solution”.

Sample

input

4

1 2 -1
2 3 4 -1
2 -1
4 -1

output

1 2 3

题目大意

一共有N个技术员和N个阀门,技术员每人负责一个或多个阀门。当一个技术员接到指示后他就会把所有自己负责的阀门都转动一次。求哪些技术员应接到指示,从而使所有阀门都打开。

思路

高斯消元,把所有的减号换成异或。

代码

#include 
#include
const int maxn=250;int n,ans[maxn+1],tot;struct matrix{ int a[maxn+1][maxn+2]; inline int gauss() { for(register int i=1; i
n) { return 1; } for(register int k=i; k<=n+1; ++k) { std::swap(a[i][k],a[j][k]); } } for(register int j=i+1; j<=n; ++j) { if(a[j][i]) { for(register int k=i; k<=n+1; ++k) { a[j][k]^=a[i][k]; } } } } for(register int i=n; i>1; --i) { for(register int j=1; j

转载于:https://www.cnblogs.com/Canopus-wym/p/10376246.html

你可能感兴趣的文章
Android图表日历控件组件
查看>>
Linux下的网络环境配置
查看>>
mysql---总体备份和增量备份
查看>>
裸机代码(uboot) : clear bss
查看>>
PHP判断访问者手机移动端还是PC端的函数,亲测好用
查看>>
http://jingyan.baidu.com/article/bad08e1ee14ae409c85121cf.html
查看>>
perf之record
查看>>
C#中的数据格式转换 (未完待更新)
查看>>
启动vsftpd失败
查看>>
yii2组件之下拉框带搜索功能(yii-select2)
查看>>
Java串口通信详解
查看>>
Newtonsoft 自定义输出内容
查看>>
HTML图片元素(标记)
查看>>
windows server 2008 域控安装
查看>>
编写高质量代码:改善Java程序的151个建议(第1章:JAVA开发中通用的方法和准则___建议6~10)...
查看>>
Oracle查看和修改连接数(进程/会话/并发等等)
查看>>
【SpringMVC学习06】SpringMVC中的数据校验
查看>>
Laravel错误与日志处理
查看>>
微信小程序开发教程第七章:微信小程序编辑名片页面开发
查看>>
Java并发编程:Java ConcurrentModificationException异常原因和解决方法
查看>>