锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲美女av在线播放,欧美精品一区二区三,另类人畜视频在线http://m.shnenglu.com/Ylemzy/archive/2011/04/09/143802.html鐏⒊榛?/dc:creator>鐏⒊榛?/author>Sat, 09 Apr 2011 05:51:00 GMThttp://m.shnenglu.com/Ylemzy/archive/2011/04/09/143802.htmlhttp://m.shnenglu.com/Ylemzy/comments/143802.htmlhttp://m.shnenglu.com/Ylemzy/archive/2011/04/09/143802.html#Feedback0http://m.shnenglu.com/Ylemzy/comments/commentRss/143802.htmlhttp://m.shnenglu.com/Ylemzy/services/trackbacks/143802.html闃呰鍏ㄦ枃

]]>
1904 King's Quest鈥斺斾簩鍒嗗浘緇撴瀯錛屽己榪為氬垎閲忕畻娉曪紝瀵規(guī)瘮涔嬪墠鐨勶紝榪欎釜鎵嶇畻姝g‘鐨則arjanhttp://m.shnenglu.com/Ylemzy/archive/2011/04/02/143310.html鐏⒊榛?/dc:creator>鐏⒊榛?/author>Sat, 02 Apr 2011 13:09:00 GMThttp://m.shnenglu.com/Ylemzy/archive/2011/04/02/143310.htmlhttp://m.shnenglu.com/Ylemzy/comments/143310.htmlhttp://m.shnenglu.com/Ylemzy/archive/2011/04/02/143310.html#Feedback0http://m.shnenglu.com/Ylemzy/comments/commentRss/143310.htmlhttp://m.shnenglu.com/Ylemzy/services/trackbacks/143310.htmlKing's Quest

Description
Once upon a time there lived a king and he had N sons. And there were N beautiful girls in the kingdom and the king knew about each of his sons which of those girls he did like. The sons of the king were young and light-headed, so it was possible for one son to like several girls.

So the king asked his wizard to find for each of his sons the girl he liked, so that he could marry her. And the king's wizard did it -- for each son the girl that he could marry was chosen, so that he liked this girl and, of course, each beautiful girl had to marry only one of the king's sons.

However, the king looked at the list and said: "I like the list you have made, but I am not completely satisfied. For each son I would like to know all the girls that he can marry. Of course, after he marries any of those girls, for each other son you must still be able to choose the girl he likes to marry."

The problem the king wanted the wizard to solve had become too hard for him. You must save wizard's head by solving this problem.

Input
The first line of the input contains N -- the number of king's sons (1 <= N <= 2000). Next N lines for each of king's sons contain the list of the girls he likes: first Ki -- the number of those girls, and then Ki different integer numbers, ranging from 1 to N denoting the girls. The sum of all Ki does not exceed 200000.

The last line of the case contains the original list the wizard had made -- N different integer numbers: for each son the number of the girl he would marry in compliance with this list. It is guaranteed that the list is correct, that is, each son likes the girl he must marry according to this list.

Output
Output N lines.For each king's son first print Li -- the number of different girls he likes and can marry so that after his marriage it is possible to marry each of the other king's sons. After that print Li different integer numbers denoting those girls, in ascending order.

Sample Input

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

Sample Output

2 1 2
2 1 2
1 3
1 4

棰樻剰錛氱粰鍑轟竴涓猲瀵筺鐨勪簩鍒嗗浘浠ュ強瀹冪殑涓涓渶澶у尮閰峂錛岄棶瀵逛竴涓偣錛屽彲浠ラ変粈涔堢偣錛屼嬌寰楀叾浠栫偣浠嶇劧鍙互寰楀埌鏈澶у尮閰嶃?br>瀵逛簬xi鍠滄鐨刴m錛岃繛涓鏉″崟鍚戣竟錛屽浜庣粰鍑虹殑鍖歸厤錛屼粠mm榪炲悜閭d釜鐢風(fēng)敓銆?br>鍒嗘瀽錛氬浜庣粰鍑虹殑鍖歸厤涓璛闆嗗悎錛屼粠xi鍑哄彂鐪嬬湅鏄惁鏈夊叾浠栦氦閿欒礬寰勶紝浣垮緱xi鍙互閫夊叾浠栧コ浜恒傚浜庣粰鍑虹殑鍖歸厤xi->yi,鐜板湪灝濊瘯浠巟i鍑哄彂閫夊埆鐨勫コ瀛﹛i->Y-yi錛岀湅鏈鍚庤兘鍚﹁揪鍒扮粓鐐箉i錛屽艦鎴愪竴涓幆銆傚鏋滃瓨鍦ㄨ繖鏍風(fēng)殑璺緞錛屽垯璺緞浼氱粡榪囦竴鏍峰鐨剎鐐硅窡y鐐癸紝浣垮緱涓涓瀵瑰簲錛岃繖鏉¤礬寰勪腑鍒嗕負(fù)涓ゆ潯浜ら敊璺緞錛屼竴涓槸鍘熸潵鐨勫尮閰嶏紝涓涓槸鍙︿竴涓彲琛屾浛鎹㈠尮閰嶏紝閫氳繃濂充漢璧板埌鐢蜂漢鐨勬槸緇欏畾鐨凪涓殑杈癸紝浠庣敺浜鴻蛋鍒板コ浜虹殑鏄潪鍖歸厤鐨勮竟銆傞偅涓涓嚭鍙戠偣xi鍙互瀛樺湪澶氫釜榪欐牱鐨勭幆錛岄棶棰樺氨鎴愪負(fù)鎵懼己榪為氬垎閲忥紝xi鍙互閰嶅鐨勫コ浜哄氨鍦ㄩ偅榪為氬垎閲忛噷銆?
#include <iostream>
#include 
<stdlib.h>
#include 
<stdio.h>
#define maxn 4100 
#define Min(a, b) a < b ? a : b
using namespace std;
struct T
{
    
int v, next;
}fn[maxn 
* maxn];
int g[maxn], ans[maxn];
int stack[maxn], visit[maxn], scc[maxn], dfn[maxn], low[maxn], instack[maxn];
int n, th, top, id, time;
int cmp(const void * a, const void * b)
{
    
return *((int*)a) - *((int*)b);
}
void set()
{
    
int i;
    th 
= 1;
    
for (i = 0; i <= 2 * n; i++)
    {
        g[i] 
= -1;
    }
}
void add(int u, int v)
{
    fn[th].v 
= v, fn[th].next = g[u], g[u] = th++;
}
void dfs(int u)
{
    
int v, k;
    dfn[u] 
= low[u] = ++time;
    stack[
++top] = u;//鏍堜粠1寮濮?/span>
    instack[u] = 1;//鏍囪榪涙爤
    for (k = g[u]; k != -1; k = fn[k].next)
    {
        v 
= fn[k].v;
        
if (dfn[v] == 0)//dfn鏄椂闂存埑錛岄兘鍒濆鍖栦負(fù)0錛岃璁塊棶榪囩殑搴楀甫鏈夋椂闂?/span>
        {
            dfs(v);
            low[u] 
= Min(low[u], low[v]);
        }
        
else if (instack[v])//濡傛灉鍦ㄦ爤涓紝鍒欒〃紺鴻鐐規(guī)病琚綊鍏ヤ換浣曚竴涓猻cc涓紝榪樺湪褰撳墠鎼滅儲鏍?wèi)涓?/span>
        {
            low[u] 
= Min(low[u], low[v]);
        }
    }
    
if (dfn[u] == low[u])
    {
        id
++;
        
do
        {
            v 
= stack[top--];
            instack[v] 
= 0;//闃叉浜ゅ弶杈歸暱鏃惰繘琛宭ow[u] = Min(low[u], low[v]).鍥犱負(fù)v宸茬粡灞炰簬涓涓繛閫氬垎閲?/span>
            scc[v] = id;
        }
while (v != u);
    }
}
void tarjan()
{
    id 
= 0, top = 0, time = 0;
    
int t = 0, i;
    
for (i = 1; i <= 2 * n; i++)
    {
        dfn[i] 
= 0;//瑕佽涓?
        scc[i] = i;
        instack[i] 
= 0;//瑕佽涓?
    }
    
for (i = 1; i <= 2 * n; i++)
    {
        
if (!dfn[i])
        {
            dfs(i);
        }
    }
}
int main()
{
    
int i, j, k, m, v;
    
while (scanf("%d"&n) - EOF)
    {
        
set();
        
for (i = 1; i <= n; i++)
        {
            scanf(
"%d"&m);
            
while (m--)
            {
                scanf(
"%d"&v);
                add(i, v 
+ n);
            }
        }
        
for (i = 1; i <= n; i++)
        {
            scanf(
"%d"&v);
            add(v 
+ n, i);
        }
        tarjan();
        
for (i = 1; i <= n; i++)
        {
            
for (j = g[i], k = 0; j != -1; j = fn[j].next)
            {
                v 
= fn[j].v;
                
if (scc[i] == scc[v])
                {
                    ans[k
++= v - n;
                }
            }                
            qsort(ans, k, 
sizeof(int), cmp);
            
for (printf("%d", k), j = 0; j < k; j++)
            {
                printf(
" %d", ans[j]);
            }printf(
"\n");
        }
    }
    
return 0;
}
/*
3
2 1 2
3 1 2 3
2 2 3
1 2 3

2
2 1 2
2 1 2
1 2

input : 
5
3 3 4 5
2 4 5
1 3
3 1 2 3
3 1 4 5
5 4 3 2 1

output : 
2 4 5
2 4 5
1 3
1 2
1 1

*/




]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲狠狠婷婷| 欧美色图一区二区三区| 美女在线一区二区| 久久久亚洲精品一区二区三区| 亚洲视频在线一区| 亚洲一区二区免费视频| 亚洲在线免费| 久久精品天堂| 欧美超级免费视 在线| 欧美激情麻豆| 一区二区日韩精品| 99热免费精品| 欧美在线影院在线视频| 久久综合九色综合久99| 免费91麻豆精品国产自产在线观看| 久久综合九色综合欧美狠狠| 亚洲黄色大片| 狠狠色综合网站久久久久久久| 欧美成人第一页| 女女同性女同一区二区三区91| 女生裸体视频一区二区三区| 欧美三级乱人伦电影| 欧美日韩高清在线观看| 国产亚洲欧洲997久久综合| 亚洲三级电影在线观看| 亚洲欧美在线免费| 毛片精品免费在线观看| 欧美韩日视频| 亚洲欧美一区二区在线观看| 欧美成人免费va影院高清| 国产精品综合av一区二区国产馆| 亚洲日本va午夜在线电影| 欧美一区二视频| 亚洲精品久久久久久久久久久久 | 看欧美日韩国产| 国产精品成人一区二区网站软件| 在线免费观看日韩欧美| 欧美一区二区三区视频免费| 91久久精品久久国产性色也91| 欧美在线观看一区二区| 国产精品区一区二区三区| 亚洲免费电影在线观看| 免费高清在线一区| 久久9热精品视频| 国产精品第一区| 一区二区三区高清在线观看| 欧美黄色免费网站| 久久中文字幕一区| 亚洲福利视频网站| 免费不卡视频| 蜜桃av噜噜一区| 激情欧美一区二区三区在线观看| 亚洲免费一区二区| 亚洲国产精品va| 模特精品在线| 亚洲国产色一区| 亚洲国产99| 欧美国产日韩一区二区三区| 伊人成人网在线看| 另类图片综合电影| 久久精品亚洲热| 激情久久中文字幕| 免费日韩成人| 久久综合九色| 亚洲日本欧美| 亚洲经典三级| 欧美日韩不卡在线| 亚洲一区二区视频| 亚洲性夜色噜噜噜7777| 国产精品中文字幕欧美| 久久久久久亚洲精品不卡4k岛国| 亚洲视频成人| 国产一区二区欧美| 欧美一区久久| 亚洲第一色在线| 久久久久综合一区二区三区| 久久天天狠狠| 六月婷婷一区| 永久555www成人免费| 午夜激情一区| 欧美中文在线免费| 国产精品第2页| 亚洲尤物在线| 欧美一区1区三区3区公司| 欧美精品二区三区四区免费看视频| 久久成人免费网| 国产女主播一区二区三区| 日韩视频在线播放| 亚洲欧美日韩天堂| 国产日产欧产精品推荐色 | 六十路精品视频| 欧美精品一区在线播放| 亚洲欧美成人| 亚洲美女黄色| 亚洲乱码国产乱码精品精98午夜| 久久亚洲精品伦理| 久久视频在线视频| 美女爽到呻吟久久久久| 久久国内精品自在自线400部| 一区二区三区欧美亚洲| 一区二区三区产品免费精品久久75 | 亚洲视频999| 亚洲黄页一区| 亚洲精品乱码久久久久久久久| 蜜桃av一区二区| 欧美国产第一页| 91久久极品少妇xxxxⅹ软件| 免费在线播放第一区高清av| 久久色在线观看| 亚洲国产91精品在线观看| 亚洲人成啪啪网站| 亚洲一区二区三区四区中文| 亚洲欧美日韩久久精品| 欧美一区二区三区的| 亚洲欧美综合国产精品一区| 一级日韩一区在线观看| 亚洲日本欧美天堂| 亚洲午夜视频在线观看| 亚洲欧美日韩视频一区| 亚洲专区免费| 久久久久国产成人精品亚洲午夜| 亚洲精品欧美一区二区三区| 亚洲美女视频网| 欧美中文在线观看| 久久激情视频免费观看| 亚洲欧美久久| 久久国产精品亚洲va麻豆| 久久精品在线视频| 欧美大片免费观看在线观看网站推荐| 欧美 日韩 国产 一区| 国产精品草草| 国产偷久久久精品专区| 国产精品99久久久久久有的能看| 久久天天躁狠狠躁夜夜爽蜜月| 亚洲精品日日夜夜| 久久综合狠狠| 国产亚洲成精品久久| aa亚洲婷婷| 久久综合久久久| 亚洲午夜91| 欧美 日韩 国产 一区| 99国产麻豆精品| 免费一区视频| 亚洲免费观看在线视频| 免费观看在线综合| 久久久久久久高潮| 国产在线不卡精品| 久久久久久尹人网香蕉| 欧美在线免费播放| 国产区在线观看成人精品| 午夜免费日韩视频| 香蕉成人啪国产精品视频综合网| 国产精品天天摸av网| 久久精品一区二区三区四区| 狼人社综合社区| 香蕉乱码成人久久天堂爱免费 | 一卡二卡3卡四卡高清精品视频 | 一区二区三区高清在线观看| 乱中年女人伦av一区二区| 亚洲图片你懂的| 亚洲欧美日韩国产一区| 国产亚洲欧美一区二区| 亚洲国产高潮在线观看| 国产欧美日韩高清| 欧美国产在线观看| 国产欧美精品日韩区二区麻豆天美| 亚洲一区视频| 欧美激情视频在线播放 | 欧美一区二区高清| 久久免费视频网站| 亚洲一区二区综合| 在线播放亚洲| 久久国产精品一区二区| 999在线观看精品免费不卡网站| 久久精品99| 欧美一区二区三区视频| 国产精品久久久久高潮| 一区二区三区日韩| 欧美国产在线电影| 亚洲无线视频| 亚洲国产小视频在线观看| 99在线精品观看| 免播放器亚洲| 午夜精品亚洲| 国产精品一区毛片| 亚洲在线视频观看| 亚洲经典自拍| 欧美成人午夜| 在线观看成人网| 久久理论片午夜琪琪电影网| 亚洲国产色一区| 久久一区精品| 一区二区电影免费观看| 免费影视亚洲| 你懂的国产精品| aa日韩免费精品视频一| 亚洲桃花岛网站| 国产精品亚发布| 久久亚洲精品网站| 欧美日韩一区在线视频|