Looksery Party

Solution:

  仔细分析一下会发现每个人都会发一条消息给自己这个条件非常重要!

这个条件保证了一定会有解,而且解法也要从这里入手。

当我们拿到一个猜测的答案序列的时候,假设这个序列没有0,那我们一个人都不需要邀请。

存在0的时候先邀请答案是0的人,然后对在它联系人列表的人的答案进行减一操作,这样操作之后可能会让一些数减小到0,但是因为每个人能联系自己,必然可以将所有的0减掉,所以必然存在解。只要把我们选择的人记录下来就好。

#include <bits/stdc++.h>

using namespace std;
const int N = ;
deque<int> q;
int a[N], G[N][N], use[N];
int n;
vector<int> ans;
string st; int main()
{
cin >> n;
for( int i = ; i <= n; ++i ) {
cin >> st;
for( int j = ; j < n; ++j ) {
G[i][j + ] = ( st[j] == '' );
}
}
for( int i = ; i <= n; ++i ) {
cin >> a[i];
if( a[i] == ) q.push_back( i );
} while( !q.empty() ) {
int x = q.front();
q.pop_front();
if( use[x] ) continue;
use[x] = ;
ans.push_back( x );
for( int i = ; i <= n; i++ ) {
if( !use[i] && G[x][i] ) {
if( --a[i] == ) q.push_back( i );
}
}
}
cout << ans.size() << endl;
for( int &i : ans ) {
cout << i << " ";
}
}

Codeforces 549B Looksery Party的更多相关文章

  1. Codeforces 549B. Looksery Party[构造]

    B. Looksery Party time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  2. CF 549B Looksery Party

    题面 解题思路 如果a数组全部>0,那么都不去即可.从这个角度出发,每次选出a[i]为0的,让它们去更新a数组,相当于拓补排序. 代码 #include<iostream> #inc ...

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

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

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

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

  6. codeforces Looksery Cup 2015 C. The Game Of Parity

    There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play t ...

  7. Looksery Cup 2015 A. Face Detection 水题

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

  8. Looksery Cup 2015 B. Looksery Party 暴力

    B. Looksery Party Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/pro ...

  9. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

随机推荐

  1. Mac下go语言goclipse插件安装部署

    Try using this URL as a Eclipse Software Site:https://raw.githubusercontent.com/GoClipse/goclipse.gi ...

  2. Bzoj 2120: 数颜色 && 2453: 维护队列 莫队,分块,bitset

    2120: 数颜色 Time Limit: 6 Sec  Memory Limit: 259 MBSubmit: 2645  Solved: 1039[Submit][Status][Discuss] ...

  3. tomcat详细日志配置

    在server.xml里的<host>标签下加上<Valve className="org.apache.catalina.valves.AccessLogValve&qu ...

  4. coco2dx 精灵类

    CCSize size = CCDirector::sharedDirector()->getWinSize(); CCSprite *bg = CCSprite::create("H ...

  5. Cow Sorting(置换)

    http://poj.org/problem?id=3270 // File Name: poj3270.cpp // Author: bo_jwolf // Created Time: 2013年1 ...

  6. storm spout的速度抑制问题

    转发请注明原文地址:http://www.cnblogs.com/dongxiao-yang/p/6031398.html 最近协助同事优化一个并发消费kafka数据用来计算的任务,压测过程中发现有两 ...

  7. EL表达式及其定义和使用 转

    作者:http://blog.csdn.net/goskalrie/article/details/51315397 简介 EL(Expression Language)表达式语言实在JSP2.0版本 ...

  8. Servlet/jsp 中 获取页面所有传递参数

    Enumeration en = request.getParameterNames(); while(en.hasMoreElements()){ String el = en.nextElemen ...

  9. 再次轻度破解EXE文件

    在经历股市多年的大起大落.大赚大赔之后.痛定思痛.深切感到在金融市场拼搏.必须建立健全交易纪律守则,严格运行. 这套完整的纪律守则,就是"交易系统". 在很多方面,它与一般的专家系 ...

  10. 分布式服务框架 Zookeeper -- 管理分布式环境中的数据--转载

    原文:http://www.ibm.com/developerworks/cn/opensource/os-cn-zookeeper/ Zookeeper 分布式服务框架是 Apache Hadoop ...