麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

poj 2367 拓?fù)渑判?/h1>
2019-11-11 05:12:25
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

The system of Martians’ blood relations is confusing enough. Actually, Martians bud when they want and where they want. They gather together in different groups, so that a Martian can have one parent as well as ten. Nobody will be surPRised by a hundred of children. Martians have got used to this and their style of life seems to them natural. And in the Planetary Council the confusing genealogical system leads to some embarrassment. There meet the worthiest of Martians, and therefore in order to offend nobody in all of the discussions it is used first to give the floor to the old Martians, than to the younger ones and only than to the most young childless assessors. However, the maintenance of this order really is not a trivial task. Not always Martian knows all of his parents (and there’s nothing to tell about his grandparents!). But if by a mistake first speak a grandson and only than his young appearing great-grandfather, this is a real scandal. Your task is to write a program, which would define once and for all, an order that would guarantee that every member of the Council takes the floor earlier than each of his descendants. Input The first line of the standard input contains an only number N, 1 <= N <= 100 — a number of members of the Martian Planetary Council. According to the centuries-old tradition members of the Council are enumerated with the natural numbers from 1 up to N. Further, there are exactly N lines, moreover, the I-th line contains a list of I-th member’s children. The list of children is a sequence of serial numbers of children in a arbitrary order separated by spaces. The list of children may be empty. The list (even if it is empty) ends with 0. Output The standard output should contain in its only line a sequence of speakers’ numbers, separated by spaces. If several sequences satisfy the conditions of the problem, you are to write to the standard output any of them. At least one such sequence always exists. Sample Input 5 0 4 5 1 0 1 0 5 3 0 3 0 Sample Output 2 4 5 3 1 又長(zhǎng)又臭的題目:每一行給幾個(gè)數(shù),要求行序號(hào)在這些數(shù)前面。證明這幾個(gè)數(shù)一定要在行序號(hào)出現(xiàn)后再出現(xiàn),拓?fù)渑判?/p>#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>using namespace std;const int maxn = 101000;#define inf 0x3f3f3f3fint e[1010][1010];int in[1010];int res[1010];int main(){ int n; while(cin>>n) { int tot=0; memset(in,0,sizeof(in)); memset(e,0,sizeof(e)); for(int i=1;i<=n;i++) { int x; while(cin>>x&&x) { e[i][x]=1; in[x]++; } } for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { if(!in[j]) { res[tot++]=j; in[j]=-1; for(int k=1;k<=n;k++) { if(e[j][k]) in[k]--; } break; } } } printf("%d",res[0] ); for(int i=1;i<tot;i++) { printf(" %d",res[i] ); } printf("/n"); }}

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

主站蜘蛛池模板: 国产精品热 | 最新中文字幕在线视频 | 成年片在线观看 | 国产一级淫片在线观看 | 日本一道aⅴ不卡免费播放 久久久久久久高清 | 亚洲福利在线免费观看 | 91久久一区| 欧美三日本三级少妇三级99观看视频 | 香蕉视频18| 精品国产一区二区三区天美传媒 | 国产精品一区二区在线 | 久久55| 美女黄影院 | 国产日韩免费观看 | 一级毛片在线观看免费 | 深夜视频在线观看 | 福利一区二区三区视频在线观看 | www.99久久久 | av大全在线免费观看 | 国产91精品亚洲精品日韩已满 | 一级一片免费看 | 中国成人在线视频 | 久草在线视频网 | 羞羞视频免费网站男男 | 黄色二区三区 | 婷婷久久网| 亚洲性综合网 | 欧美大胆xxxx肉体摄影 | 欧美成人国产va精品日本一级 | 一区二区久久电影 | 国产精品成人亚洲一区二区 | 久久久鲁 | 做爰xxxⅹ性护士hd在线 | 久久密| 午夜久 | 久久免费视屏 | 亚洲精品7777 | 精品久久久久久中文字幕 | 亚洲综合网站 | 国产剧情v888av | 久产久精品 |