题面

解题思路

如果a数组全部>0,那么都不去即可。从这个角度出发,每次选出a[i]为0的,让它们去更新a数组,相当于拓补排序。

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue> using namespace std;
const int MAXN = 105; int n,a[MAXN][MAXN],re[MAXN];
int cnt,ans[MAXN];
bool vis[MAXN];
queue<int> Q; int main(){
scanf("%d",&n);
for(register int i=1;i<=n;i++){
char ch[MAXN];
scanf("%s",ch+1);
for(register int j=1;j<=n;j++){
int x=ch[j]-'0';
a[i][j]=x;
}
}
for(register int i=1;i<=n;i++){
scanf("%d",&re[i]);
if(re[i]==0){Q.push(i);vis[i]=1;ans[++cnt]=i;} }
if(Q.empty()) {puts("0");return 0;}
while(Q.size()){
int x=Q.front();Q.pop();
for(register int i=1;i<=n;i++)if(!vis[i])
if(a[x][i]==1) {
re[i]--;
if(re[i]==0) {
vis[i]=1;
Q.push(i);
ans[++cnt]=i;
}
}
}
printf("%d\n",cnt);
for(register int i=1;i<=cnt;i++)
printf("%d ",ans[i]);
return 0;
}

CF 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. Codeforces 549B Looksery Party

    Looksery Party Solution: 仔细分析一下会发现每个人都会发一条消息给自己这个条件非常重要! 这个条件保证了一定会有解,而且解法也要从这里入手. 当我们拿到一个猜测的答案序列的时候 ...

  3. Looksery Cup 2015 Editorial

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

  4. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

  5. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  6. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

  7. ARC下OC对象和CF对象之间的桥接(bridge)

    在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...

  8. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  9. CF memsql Start[c]UP 2.0 A

    CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...

随机推荐

  1. 2 _ 基本框架 _ 检测VMX环境

    VT 是先开为大,谁先开谁上层,谁上层 谁权限大. 1 判断是否支持 VMX intel 白皮书 第3卷 传入 参数eax =1, 返回值 ecx 的第5位 = 1 则 surpported VMX. ...

  2. 【学术篇】luogu1558&&poj2777 色板游戏

    题目の传送门: luogu:https://www.luogu.org/problem/show?pid=1558 poj:http://poj.org/problem?id=2777 题目大意:给有 ...

  3. Powerdesigner 生成数据字典

    https://www.jianshu.com/p/f491d0d3c503http://blog.csdn.net/adparking/article/details/50402980http:// ...

  4. String相加解析

    Java代码 package com.utils.test; public class TestObject { public static void main(String[] args) { St ...

  5. Python3基础笔记_字符串类型

    # 1.Python转义字符 a = "sqwerdf" # 2.Python字符串运算符 ''' + 字符串连接 a + b 输出结果: HelloPython * 重复输出字符 ...

  6. LUOGU P1505 [国家集训队]旅游 (树链剖分+线段树)

    传送门 解题思路 快被调死的码农题,,,其实就是一个边权下放到点权的线段树+树剖. #include<iostream> #include<cstdio> #include&l ...

  7. 【自家测试】2017-12-16 FJOI2016 d1

    1. 所有公共子序列问题(allcs.pas/c/cpp)★问题描述:一个给定序列的子序列是在该序列中删去若干元素后得到的序列.确切地说,若给定序列X= x 1 x 2 ... x m ,则另一序列Z ...

  8. js微信禁止分享

    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js ...

  9. python多线程建立代理ip池

    之前有写过用单线程建立代理ip池,但是大家很快就会发现,用单线程来一个个测试代理ip实在是太慢了,跑一次要很久才能结束,完全无法忍受.所以这篇文章就是换用多线程来建立ip池,会比用单线程快很多.之所以 ...

  10. Codeforces 938G 线段树分治 线性基 可撤销并查集

    Codeforces 938G Shortest Path Queries 一张连通图,三种操作 1.给x和y之间加上边权为d的边,保证不会产生重边 2.删除x和y之间的边,保证此边之前存在 3.询问 ...