poj 3660 Cow Contest ([kuangbin带你飞]专题四 最短路练习)

现代密码学5.3--Hash and MAC 现代密码学5.3--Hash and MAC 博主正在学习INTRODUCTION TO MODERN CRYPTOGRAPHY (Second Edition) --Jonathan Katz, Yehuda Lindell,做一些笔记供自己回忆,如有错误请指正。整理成一个系列现代密码学,方便检索。 第二章定义了完美安全及其对应的密码方案“一次一密”, 第三章介绍了多种安全定义 3.1-3.3 计算安全,PRG和基于PRG构造的满足计算安全的密码方案; 3.4-3.5 CPA安全,PRF和基于PRF构 阅读详情

Description

N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that is unique among the competitors.

The contest is conducted in several head-to-head rounds, each between two cows. If cow A has a greater skill level than cow B (1 ≤ A ≤ N; 1 ≤ B≤ N; A ≠ B), then cow A will always beat cow B.

Farmer John is trying to rank the cows by skill level. Given a list the results of M (1 ≤ M ≤ 4,500) two-cow rounds, determine the number of cows whose ranks can be precisely determined from the results. It is guaranteed that the results of the rounds will not be contradictory.

Input

* Line 1: Two space-separated integers: N and M
* Lines 2..M+1: Each line contains two space-separated integers that describe the competitors and results (the first integer, A, is the winner) of a single round of competition: A and B

Output

* Line 1: A single integer representing the number of cows whose ranks can be determined
 

Sample Input

5 5
4 3
4 2
3 2
1 2
2 5

Sample Output

2



题目大意:给出牛之间的强弱关系,让你确定有多少头牛能够确定其排名.

解题思路:只要知道眉头牛和其他牛的强弱关系就可以知道这个牛的强弱,,


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m;
const int maxn = 100+10;
int mp[maxn][maxn];

int main(){
    while(scanf("%d%d",&n,&m)!=EOF){
        memset(mp,0,sizeof(mp));
        for(int i=1;i<=m;i++){
            int a,b;
            scanf("%d%d",&a,&b);
            mp[a][b]=1;
        }
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                    if(mp[i][k] && mp[k][j]) mp[i][j]=1;
                }
            }
        }
        int ans=0;
        for(int i=1;i<=n;i++){
            int res= n-1;
            for(int j=1;j<=n;j++){
                if(mp[i][j] || mp[j][i]) res--;
            }
            if(!res) ans++;
        }
        printf("%d\n",ans);
    }





    return 0;
}









深度解析长鑫G5 DRAM工艺的技术逻辑与微缩边界 长鑫存储G5 DRAM平台通过多重图形化、45:1高深宽比电容与外围HKMG技术,突破先进光刻受限瓶颈,在11.95 nm有源区半间距下实现阵列微缩与电容结构优化。其核心意义不在于对标国际节点,而在于系统性解决“尺寸缩小—电荷保持—外围跟进而”三大矛盾,展现国产DRAM在无EUV条件下推进先进制程的工艺整合能力。 阅读详情

相关推荐

Discrete Optimization (Coursera) 学习笔记 Week 1 introduction (开个帖子)

Week 1 Introduction 这位教授Pascal Van Hentenryck 真的算是优化领域神级别的人物了吧?截一张Google scholar的图大家感受一下… 居然在Coursera上看到了他开的课:Discrete Optimization。试听了几节后,发现讲得很有激情,而且深入浅出。遂决定花暑假跟完这一门课。 这门课每周花两三个小时介绍基础概念,然后得花十几个小时写作业(coding)… 一开始以为Coursera上的课的作业应该不会太难,然后第一次作业(knapsack)我就被

ZJ_11701的博客 656

[kuangbin带你飞]专题四 最短路练习

Til the Cows Come Home 题意为问 NNN 到 111 的最短距离,直接套模板求单源最短路就好 #include &amp;amp;amp;lt;cstdio&amp;amp;amp;gt; #include &amp;amp;amp;lt;algorithm&amp;amp;amp;gt; #include &amp;amp;amp;lt;queue&amp;amp;amp;gt; #include &amp;amp;amp;lt

x_shuai的博客 369

Kylin V10 ARM64离线安装ffmpeg实战指南

在国产化替代浪潮下,基于银河麒麟V10和ARM架构(如飞腾、鲲鹏)的内网服务器部署音视频处理服务成为常态。由于系统默认软件源缺乏aarch64包且无法连接外网,常规yum安装方式难以奏效。本文从离线安装的通用概念出发,剖析了在Kylin V10上安装ffmpeg的三大路线及其原理,重点介绍了源码编译法,包括依赖梳理、工具链准备、编译参数配置、常见错误排查等关键环节。同时,将这套依赖管理与离线部署方法论延伸至nginx、node.js、Python库及docker等场景,帮助读者建立一套可复用的国产化系统离线

weixin_33417488的博客 148

[kuangbin带你飞]专题四 最短路练习 A

Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get ba

yqdjl6的博客 358

MIPS-5级流水线CPU

一、流水线CPU 流水线CPU就是指将一条分解为多步,在同一周期内进行多条指令的同时执行。MIPS五级流水线就是将指令分为:取指(IF),译码(ID),执行(EX),访存(MEM),写回(WB)五个阶段。举个例子: 比如第二条指令lui $t2,0x2100 在流水线CPU中执行的就是 可以看到在200-300ns的周期里,IF阶段取到0x00400004处的指令,300-400ns,这条指令到了ID阶段,而IF阶段执行下一条指令。400-500ns,执行这条指令,ALU的结果为0x2100

weixin_43877853的博客 2万+

飞书+扣子+DeepSeek三件套:5分钟搞定公众号文章批量改写(附完整配置截图)

本文详细介绍了如何利用飞书、扣子和DeepSeek三款工具,无需编程即可搭建一个高效的公众号文章批量改写自动化工作流。通过飞书多维表格管理链接与成果,扣子平台串联整个流程,并调用DeepSeek智能体进行内容润色与改写,实现从内容抓取到智能处理的完整自动化,大幅提升新媒体运营效率。

python9snake的博客 208

[kuangbin带你飞]专题四 最短路练习 题解

专题四 最短路练习POJ 2387Til the Cows Come HomePOJ 2253FroggerPOJ 1797Heavy TransportationPOJ 3268Silver Cow PartyPOJ 1860Currency ExchangePOJ 3259WormholesPOJ 1502MPI MaelstromPOJ 3660Cow ContestPOJ...

一叶之修的博客 405

心电图机原理及电路超详细讲解

前置心电放大电路(虚线框:这是隔离电路的分界,在隔离电路分析中知道,完整隔离包括信号隔离(脉宽调制)、控制信号隔离(光电耦合)和电源隔离)后级放大电路。

fcxgfdjy的博客 2万+

kuangbin最短路专题Cow Contest POJ - 3660

kuangbin最短路.8 传送门 题意 给出mmm个关系(a,b)(a,b)(a,b)表示aaa的能力大于bbb的能力。问能确定至少几个人的排名。 思路 数据范围n<=100n<=100n<=100 ,且存在递推关系(a>b且b>ca>b且b>ca>b且b>c推出a>ca>ca>c),考虑用floyd。同时,如果一个点,和其他所有点都存在关系,可以断定他的排名。因为我们可以列出所有比他能力大的,和所有比他能力小的,这个点自然可以确定

Sivannn的博客 270

微信小程序marker 上的自定义气泡cover-view字体丢失以及max-width不生效问题

微信小程序marker 上的自定义气泡cover-view字体丢失以及max-width不生效问题

weixin_42028275的博客 1500

材料力学数值方法:细观力学模拟:材料断裂与损伤的细观模拟_2024-08-05_16-13-13.Tex

弹性理论是材料力学的一个重要分支,主要研究在外部载荷作用下,材料如何发生弹性变形以及如何恢复原状。这一理论基于连续介质力学,将材料视为由无数连续点组成的连续体,每个点都遵循一定的力学规律。弹性理论的核心是胡克定律,它表明在弹性范围内,应力与应变成正比关系。损伤变量ddd通常定义为0到1之间的值,其中d0d=0d0表示材料未损伤,d1d=1d1表示材料完全损伤。损伤变量可以基于不同的物理量定义,如裂纹密度、孔隙率或微观缺陷的分布。

938

[kuangbin]专题四 最短路练习 Cow Contest POJ - 3660【传递闭包】

【题目描述】 N (1 ≤ N ≤ 100) cows, conveniently numbered 1…N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that...

inv0ker的博客 187

RH850从0搭建Autosar开发环境【3X】- Davinci Configurator之Port模块配置详解(MCAL配置)

RH850从0搭建Autosar开发环境【3X】- Davinci Configurator之Port模块配置详解(MCAL配置)

weixin_42412049的博客 2277

[kuangbin带你飞]专题四 最短路练习H,I,J

H题: http://poj.org/problem?id=3660题意:给你n个点,m个关系,每个关系说明了u在v前 问能确定下来位置的点有多少tip:首先能想到一个点的前面+后面= n-1就是确定位置,那怎么知道呢? dfs啊。。。。但是这个貌似是最短路专题QAQ,那就Floyd,floyd本身的想法就是用一个中间点更新两边点的关系,这个题也是一样,前驱的前驱一定是前驱,找到所有这样的就好

zjy2015302395的博客 504

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

[kuangbin带你飞] 专题四 最短路练习 练习

1、Til the Cows Come Home 裸的最短路,wa一路发现自己T,N读入反了,据说还有重边,不过是邻接矩阵需要考虑的问题,前向星和邻接表可以忽略。 #include <iostream> #include <algorithm> #include <cstdio> #include <queue> #include <c...

CCCCTong的博客 348

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

[kuangbin带你飞]专题四 最短路练习-E

http://poj.org/problem?id=1860 DescriptionSeveral currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operat

zjy2015302395的博客 523

poj 2240 Arbitrage ([kuangbin带你飞]专题四 最短路练习)

Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar

Strive 869

poj 1860 Currency Exchange ([kuangbin带你飞]专题四 最短路练习)

Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these curren

Strive 610

poj 3259 Wormholes ([kuangbin带你飞]专题四 最短路练习)

Description While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination

Strive 590

poj 3126 Prime Path([kuangbin带你飞]专题一 简单搜索)

题目连接:题目 题目大意:两个素数,每次可以改变前一个数的某一位,并且改变完还是素数,求从第一个数变成第二个数的最小步数 解题思路:能读懂题目就差不多能知道用bfs,枚举每一位,改变数,看是不是素数, #include #include #include #include #include #include #include #include using namespace std; boo

Strive 565

POJ 3414 Pots([kuangbin带你飞]专题一 简单搜索)

题目连接:题目 题目大意:给你A,B两个杯子和一同水,问你能用两个杯子倒出C的水吗, 解题思路,这个题和非常可乐这个题很相似,其实差不多,但是这个题比较麻烦一些,,标记各种情况 #include #include #include #include #include using namespace std; int a,b,c; const int maxn = 100+5;

Strive 531

poj 1502 MPI Maelstrom([kuangbin带你飞]专题四 最短路练习)

Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee'

Strive 525

poj 1679 The Unique MST ([kuangbin带你飞]专题八 生成树 )

题目大意:给你一个无向图,问如果这个无向图的最小生成树是唯一的就输出最小生成树的权值,否则输出Not Unique! 解题思路,求次小生成树,如果次小生成树中有何最小的权值一样的,则生成树不唯一,否则唯一用Kruskal,求最小生成树,然后枚举其中一个边去掉以后(n-1条),再求最小生成树,然后和原来的权值比较, #include #include #include using nam

Strive 508

poj 3268 Silver Cow Party ([kuangbin带你飞]专题四 最短路练习)

Description One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirect

Strive 499

Dungeon Master([kuangbin带你飞]专题一 简单搜索)

题目大意:题目链接 给个多层的迷宫,求从起点到终点的最短路径,不能到达就输出Trapped! 解体思路: bfs直接搜,没什么好说的,一开始忘记清空队列一只WA,果然我还是菜鸡 #include #include #include #include #include #include using namespace std; struct node{ int x,y,z;

Strive 494
上一篇: poj 1502 MPI Maelstrom([kuangbin带你飞]专题四 最短路练习)
下一篇: poj 2240 Arbitrage ([kuangbin带你飞]专题四 最短路练习)
Strive_Buff
博客等级 码龄11年 4粉丝 80原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值