日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國(guó)內(nèi)最全I(xiàn)T社區(qū)平臺(tái) 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > php開源 > php教程 > HDU 2647 Reward(拓?fù)渑判颍?

HDU 2647 Reward(拓?fù)渑判颍?/h1>
來源:程序員人生   發(fā)布時(shí)間:2014-12-12 08:33:13 閱讀次數(shù):3197次
Problem Description
Dandelion's uncle is a boss of a factory. As the spring festival is coming , he wants to distribute rewards to his workers. Now he has a trouble about how to distribute the rewards.
The workers will compare their rewards ,and some one may have demands of the distributing of rewards ,just like a's reward should more than b's.Dandelion's unclue wants to fulfill all the demands, of course ,he wants to use the least money.Every work's reward will be at least 888 , because it's a lucky number.
 

Input
One line with two integers n and m ,stands for the number of works and the number of demands .(n<=10000,m<=20000)
then m lines ,each line contains two integers a and b ,stands for a's reward should be more than b's.
 

Output
For every case ,print the least money dandelion 's uncle needs to distribute .If it's impossible to fulfill all the works' demands ,print ⑴.
 

Sample Input
2 1 1 2 2 2 1 2 2 1
 

Sample Output
1777 ⑴
 

Author
dandelion


拓?fù)渑判颉!?/p>

#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue> typedef long long LL; using namespace std; #define REPF( i , a , b ) for ( int i = a ; i <= b ; ++ i ) #define REP( i , n ) for ( int i = 0 ; i < n ; ++ i ) #define CLEAR( a , x ) memset ( a , x , sizeof a ) const int maxn=10100; int head[maxn*2],next[maxn*2],end[maxn*2]; int in[maxn],val[maxn]; int n,m,cnt,k; void toposort() { int sum=0; k=0; queue<int>q; REPF(i,1,n) if(!in[i]) q.push(i); while(!q.empty()) { int v=q.front(); sum+=val[v]; q.pop(); k++; for(int i=head[v];i!=⑴;i=next[i]) { if(--in[end[i]]==0) { q.push(end[i]); val[end[i]]=val[v]+1; } } } if(k==n) printf("%d ",sum); else printf("⑴ "); } void add(int x,int y) { next[cnt]=head[x]; end[cnt]=y; head[x]=cnt++; } int main() { int x,y; while(~scanf("%d%d",&n,&m)) { cnt=0; REPF(i,1,n) val[i]=888; CLEAR(in,0); CLEAR(head,⑴); REP(i,m) { scanf("%d%d",&x,&y); add(y,x); in[x]++; } toposort(); } return 0; }


生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)
程序員人生

------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 国产精品18久久久久久久久久久久 | 欧美三区 | 看黄视频在线观看 | 国产香蕉视频在线播放 | 国产精品毛片无码 | 欧美日韩美女 | 日韩在线播放视频 | 国产成人精品免费视频大全最热 | 丁香婷婷综合激情五月色 | 国产免费区一区二区三视频免费 | 久久免费高清 | 国产一区二区在线免费 | 国产日韩欧美一区二区三区乱码 | 91视频免费观看 | 欧洲精品码一区二区三区免费看 | 全国免费av | 国产一二区在线 | 综合精品 | 欧美性一区二区三区 | 久久久精品一区二区三区 | 黄色一级大片在线免费看产 | 国产精品99久久久久久似苏梦涵 | 日韩欧美中文字幕在线观看 | 国产精品一区在线观看 | 精品久久久久久国产 | 亚洲欧美综合精品久久成人 | 亚洲精品乱码久久久久久动图 | 国内精品久久久久久影视8 成人午夜影院 | 国产伦精品一区二区三区四区免费 | 吞噬星空在线观看 | 国产91在线播放精品91 | 国产麻豆成人传媒免费观看 | 欧美 日韩 国产 成人 在线 91 | 国产香蕉视频 | 亚洲精品在线观看免费 | www久| 日日干日日操 | 人操人人 | 久久se精品一区精品二区 | 色综合二区| 欧美日韩性生活视频 |