B. Looksery Party

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/549/problem/B

Description

The Looksery company, consisting of n staff members, is planning another big party. Every employee has his phone number and the phone numbers of his friends in the phone book. Everyone who comes to the party, sends messages to his contacts about how cool it is. At the same time everyone is trying to spend as much time on the fun as possible, so they send messages to everyone without special thinking, moreover, each person even sends a message to himself or herself.

Igor and Max, Looksery developers, started a dispute on how many messages each person gets. Igor indicates n numbers, the i-th of which indicates how many messages, in his view, the i-th employee is going to take. If Igor guesses correctly at least one of these numbers, he wins, otherwise Max wins.

You support Max in this debate, so you need, given the contact lists of the employees, to determine whether there is a situation where Igor loses. Specifically, you need to determine which employees should come to the party, and which should not, so after all the visitors send messages to their contacts, each employee received a number of messages that is different from what Igor stated.

Input

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of employees of company Looksery.

Next n lines contain the description of the contact lists of the employees. The i-th of these lines contains a string of length n, consisting of digits zero and one, specifying the contact list of the i-th employee. If the j-th character of the i-th string equals 1, then the j-th employee is in the i-th employee's contact list, otherwise he isn't. It is guaranteed that the i-th character of the i-th line is always equal to 1.

The last line contains n space-separated integers: a1, a2, ..., an (0 ≤ ai ≤ n), where ai represents the number of messages that the i-th employee should get according to Igor.

Output

In the first line print a single integer m — the number of employees who should come to the party so that Igor loses the dispute.

In the second line print m space-separated integers — the numbers of these employees in an arbitrary order.

If Igor wins the dispute in any case, print -1.

If there are multiple possible solutions, print any of them.

Sample Input

3
101
010
001
0 1 2

Sample Output

1
1

HINT

题意

每个人都热衷发短信,就是每个人会给一个电话本,然后有个人就在猜每个人能够收到多少个短信,然后让你构造出一个数据,把这个cha掉

题解:

d[i]表示每个人还要收到多少个短信,遇到d[i]=0的就表示这个人已经符合条件了,所以我们就得派出这个人,因为每个人必然会给自己发短信,所以就不符合了

然后就用这个思路,直接扫一遍就好了

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 2000001
#define mod 10007
#define eps 1e-9
int Num;
char CH[20];
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;
}
inline void P(int x)
{Num=0;if(!x){putchar('0');puts("");return;}while(x>0)CH[++Num]=x%10,x/=10;while(Num)putchar(CH[Num--]+48);puts("");
}
//**************************************************************************************string s[maxn];
int d[maxn];
vector<int> ans;
int main()
{//test;int n=read();for(int i=0;i<n;i++)cin>>s[i];for(int i=0;i<n;i++)d[i]=read();while(1){int flag=0;for(int i=0;i<n;i++){if(d[i]==0){flag++;for(int j=0;j<s[i].size();j++){if(s[i][j]=='1')d[j]--;}ans.push_back(i+1);}}if(flag==0)break;}printf("%d\n",ans.size());sort(ans.begin(),ans.end());for(int i=0;i<ans.size();i++)cout<<ans[i]<<" ";
}

转载于:https://www.cnblogs.com/qscqesze/p/4563468.html

Looksery Cup 2015 B. Looksery Party 暴力相关推荐

  1. Looksery Cup 2015 F - Yura and Developers 单调栈+启发式合并

    F - Yura and Developers 第一次知道单调栈搞出来的区间也能启发式合并... 你把它想想成一个树的形式, 可以发现确实可以启发式合并. #include<bits/stdc+ ...

  2. Looksery Cup 2015 F. Yura and Developers(单调栈+二分+分治)(难*)

    题目链接 题意:给定一个数组,问有多少区间满足:去掉最大值之后,和是k的倍数. 思路:日后补. #include<bits/stdc++.h> using namespace std; t ...

  3. Looksery Cup 2015 H. Degenerate Matrix 数学

    H. Degenerate Matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/ ...

  4. codeforces Looksery Cup 2015 H Degenerate Matrix

    The determinant of a matrix 2 × 2 is defined as follows: A matrix is called degenerate if its determ ...

  5. Codeforces VK Cup 2015 A.And Yet Another Bracket Sequence(后缀数组+平衡树+字符串)

    这题做得比较复杂..应该有更好的做法 题目大意: 有一个括号序列,可以对其进行两种操作: ·        向里面加一个括号,可以在开头,在结尾,在两个括号之间加. ·        对当前括号序列进 ...

  6. VK Cup 2015 - Qualification Round 1 A. Reposts(树)

    传送门 Description One day Polycarp published a funny picture in a social network making a poll about t ...

  7. Facebook Hacker Cup 2015 Round 1--Corporate Gifting(树形动态规划)

    原题:https://www.facebook.com/hackercup/problems.php?pid=759650454070547&round=344496159068801 题意: ...

  8. VK Cup 2015 - Round 2 E. Correcting Mistakes —— 字符串

    题目链接:http://codeforces.com/contest/533/problem/E E. Correcting Mistakes time limit per test 2 second ...

  9. a记录 mysql_[a]-和[a]相关的内容-阿里云开发者社区

    HDOJ 1202 The calculation of GPA Problem Description 每学期的期末,大家都会忙于计算自己的平均成绩,这个成绩对于评奖学金是直接有关的.国外大学都是计 ...

  10. ceph客户端使用_ceph存储之ceph客户端

    CEPH客户端: 大多数Ceph用户不会直接往Ceph存储集群里存储对象,他们通常会选择Ceph块设备.Ceph文件系统.Ceph对象存储之中的一个或多个: 块设备: 要实践本手册,你必须先完成存储集 ...

最新文章

  1. Delphi中使用IXMLHTTPRequest如何用POST方式提交带参
  2. 让手机跑SOTA模型快8倍!Facebook AI开源最强全栈视频库:PyTorchVideo!
  3. linux ssh连接 出现 Host key verification failed 错误 解决方法
  4. Oracle 用拼接字符串更新表 测试
  5. Zookeeper基于Java访问-节点事件监听
  6. SAP CRM的订单模型移植到S4HANA后,在订单保存功能上作出的改进
  7. hdu1728--------坑爹啊
  8. 数据eda_关于分类和有序数据的EDA
  9. 对HTML标记的理解,初学者接触HTML了解一些HTML标记(1)
  10. RecyclerView数据显示不全的问题
  11. NB-IoT窄带物联网技术项目开发教程--技术简介(一)
  12. 计算机的发展共经历了哪几个阶段,1. 计算机的发展经历了哪几个阶段?各阶段的主要特征是什么,计算机的发展经历了哪些阶段?...
  13. Win10开了热点之后,电脑不能上网怎么解决?
  14. 去水印软件哪个好_去水印工具
  15. 倾角传感器的精度和线性误差的区别
  16. zipkin链路追踪详解
  17. 全世界的程序员,我只服女程序员
  18. 加强我国人工智能国防应用的研究与思考
  19. 武汉大学计算机专业网络安全,武汉大学网络空间安全考研科目有哪些?
  20. 2019年第十五届网络科学论坛会议PPT合集(含陈关荣、周涛、狄增如等大牛PPT)

热门文章

  1. 申请以及集成 Stripe 的 Alipay 支付方案
  2. android CheckBox的运用
  3. C#中可以使用正则表达式来过滤html字符
  4. php if条件循环语句,PHP:IF语句可以单独运行,但不能在WHILE循环内运行
  5. 中兴android.process.acore,中兴天机Grand SII第三方系统刷机包(卡刷包)
  6. 手机能识别sim卡但是没信号_一篇文章扫盲手机SIM卡相关知识
  7. python plot 增加标记线_Python可视化| matplotlib04-掌握标记和线型的使用,一文,marker,linestyle...
  8. python getopt使用_如何使用getopt.getoptpython中的方法?
  9. 疫情再次严峻没地蹲坑,无聊在家做单片机点亮一个发光二极管实验
  10. 正则表达式 两个符号的字段_Tableau正则提取字段部分内容