CF 549B Looksery Party
解题思路
如果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的更多相关文章
- Codeforces 549B. Looksery Party[构造]
B. Looksery Party time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Codeforces 549B Looksery Party
Looksery Party Solution: 仔细分析一下会发现每个人都会发一条消息给自己这个条件非常重要! 这个条件保证了一定会有解,而且解法也要从这里入手. 当我们拿到一个猜测的答案序列的时候 ...
- Looksery Cup 2015 Editorial
下面是题解,做的不好.下一步的目标是rating涨到 1800,没打过几次cf A. Face Detection Author: Monyura One should iterate through ...
- 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 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- cf Round 613
A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...
- ARC下OC对象和CF对象之间的桥接(bridge)
在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...
- [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现
1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...
- 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 ...
随机推荐
- mongodb 3.2 yaml 配置详解及范例
mongodb3.x版本后就是要yaml语法格式的配置文件,下面是yaml配置文件格式如下:官方yaml配置文件选项参考:https://docs.mongodb.org/manual/ ... #c ...
- spring:bean的作用范围和生命周期
bean的作用范围调整: <!--bean的作用范围调整 bean标签的scope属性: 作用:用于指定bean的作用范围 取值:常用的就是单例的和多例的 singleton:单例的(默认值) ...
- Error:Execution failed for task ':app:validateSigningDebug'.
今天出差回来 第一天 把项目重新移植到新的电脑上 一运行 给我报错了 ! 这个是签名的路径错误 我们需要重新导一下路径就可以了 点击左上角 File -> project structu ...
- 关于set_multicycle_path的最后总结
(1) –start/-end决定移动的距离以start_clock/end_clock为单元: (2) 对于-setup选项,移动距离是在默认关系的基础上移动(数值-1): (3) 默认往后, se ...
- threading.local在flask中的用法
一.介绍 threading.local的作用: 多个线程修改同一个数据,复制多份变量给每个线程用,为每个线程开辟一块空间进行数据的存储,而每块空间内的数据也不会错乱. 二.不使用threading. ...
- WebLogic使用总结(二)——WebLogic卸载[转]
一.WebLogic 12c的卸载 WebLogic的卸载是非常容易的,找到WebLogic的卸载程序,如下图所示:
- JDK源码阅读--String
public final class String implements java.io.Serializable, Comparable<String>, CharSequence St ...
- PAT甲级——A1101 Quick Sort
There is a classical process named partition in the famous quick sort algorithm. In this process we ...
- Df- Linux必学的60个命令
1.作用 df命令用来检查文件系统的磁盘空间占用情况,使用权限是所有用户. 2.格式 df [options] 3.主要参数 -s:对每个Names参数只给出占用的数据块总数. -a:递归地显示指定目 ...
- vue-admin-template模板添加tagsview
参考: https://github.com/PanJiaChen/vue-admin-template/issues/349 一.从vue-element-admin复制文件: vue-admin- ...