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[];
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void P(int x)
{
Num=;if(!x){putchar('');puts("");return;}
while(x>)CH[++Num]=x%,x/=;
while(Num)putchar(CH[Num--]+);
puts("");
}
//************************************************************************************** string s[maxn];
int d[maxn];
vector<int> ans;
int main()
{
//test;
int n=read();
for(int i=;i<n;i++)
cin>>s[i];
for(int i=;i<n;i++)
d[i]=read();
while()
{
int flag=;
for(int i=;i<n;i++)
{
if(d[i]==)
{
flag++;
for(int j=;j<s[i].size();j++)
{
if(s[i][j]=='')
d[j]--;
}
ans.push_back(i+);
}
}
if(flag==)
break;
}
printf("%d\n",ans.size());
sort(ans.begin(),ans.end());
for(int i=;i<ans.size();i++)
cout<<ans[i]<<" ";
}

Looksery Cup 2015 B. Looksery Party 暴力的更多相关文章

  1. Looksery Cup 2015 D. Haar Features 暴力

    D. Haar Features Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/prob ...

  2. Looksery Cup 2015 A. Face Detection 水题

    A. Face Detection Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/pro ...

  3. Looksery Cup 2015 Editorial

    下面是题解,做的不好.下一步的目标是rating涨到 1800,没打过几次cf A. Face Detection Author: Monyura One should iterate through ...

  4. Looksery Cup 2015 H. Degenerate Matrix 数学

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

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

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

  6. 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 ...

  7. Looksery Cup 2015 C. The Game Of Parity —— 博弈

    题目链接:http://codeforces.com/problemset/problem/549/C C. The Game Of Parity time limit per test 1 seco ...

  8. codeforces Looksery Cup 2015 D. Haar Features

    The first algorithm for detecting a face on the image working in realtime was developed by Paul Viol ...

  9. codeforces Looksery Cup 2015 H Degenerate Matrix 二分 注意浮点数陷阱

    #include <cstdio> #include <cstring> #include <algorithm> #include <string> ...

随机推荐

  1. reCAPTCHA 简单分析

    CAPTCHA项目是Completely Automated Public Turing Test to Tell Computers and Humans Apart (全自动区分计算机和人类的图灵 ...

  2. TestNG中同一个类中执行多个test()方法如何配置testng.xml

    public class IndexInfo extends BaseTesting{ private IndexPage IndexPage1;// private AddEquipmentInfo ...

  3. linux umask使用详解

    转自:http://blog.csdn.net/lmh12506/article/details/7281910 umask使用方法 A 什么是umask?   当我们登录系统之后创建一个文件总是有一 ...

  4. 容器的范围 .xml

    pre{ line-height:1; color:#f0caa6; background-color:#2d161d; font-size:16px;}.sysFunc{color:#e54ae9; ...

  5. 将数字映射到字母上 .xml

    映射成 A1------A20               B1------B20               ...               Z1------Z20 这种形式   数字从0开始编 ...

  6. IOS平台设计规范

    一.UI的控件概述: 1.框架UI的元素分为4类: A:栏:状态栏目和导航栏的结合体; B:内容视图:应用显示的内容信息,包括相关的交互行为,例如滚屏.插入.删除等操作进行排序; C:控制元素:产品行 ...

  7. Hadoop中的辅助类ToolRunner和Configured的用法详解

    在开始学习hadoop时,最痛苦的一件事就是难以理解所写程序的执行过程,让我们先来看这个实例,这个测试类ToolRunnerTest继承Configured的基础上实现了Tool接口,下面对其用到的基 ...

  8. 【openstack报错】【因更新包而致】IncompatibleObjectVersion: Version 1.9 of Instance is not supported

    [时间]2014年2月18日 [平台]ubuntu 12.04.3 openstack havana [日志]/var/log/upstart/nova-compute.log  内容如下: ERRO ...

  9. 【数据结构与算法分析——C语言描述】第一章总结 引论

    这一章主要复习了一些数学知识,像指数.对数.模运算.级数公式:还有2种证明方法,归纳假设法和反证法.所幸以前学过,重新拾捡起来也比较轻松. 简要地复习了递归,提出了编写递归例程的四条基本法则: 基准情 ...

  10. 纯JS Web在线可拖拽的流程设计器

    F2工作流引擎之-纯JS Web在线可拖拽的流程设计器 Web纯JS流程设计器无需编程,完全是通过鼠标拖.拉.拽的方式来完成,支持串行.并行.分支.异或分支.M取N路分支.会签.聚合.多重聚合.退回. ...