Codevs 1506 Messenger

Source: Internet
Author: User

Codevs 1506 Relay

1506 Message-The solution to this problem is many, can you think of several? Time limit: 1 s space limit: 128000 KB title: Silver Issue Description Description A friend network, if a knows B, then if a first received a message, then the message will be passed to B, and all a know people. If a knows b,b does not necessarily know a. All the people numbered from 1 to N, gave all the "understanding" relationships, and asked if I had released a new message, then the message would have been sent back to I,1<=i<=n after a few passes. Enter a description input description The first line is N and M, representing the number of people and the number of cognitive relationships. The next M-line, two numbers a and b per line, indicates a knows B. 1<=a, B<=n. The cognitive relationship may be repeated, but the two-digit number of a row will not be the same. The output description outputs description altogether n lines, one character per line, T or F. Line I if it is T, I send a new message will be passed back to I; if it is F, I send a new message will not be returned to I. Sample input Sample Input4 61 22 34 13 11 32 3 Sample output sample Outputtttf data size & hintn<=10001<=a,b<=n


#include <iostream> #include <cstdio> #include <cstring>using namespace std; int N,m,a,b,i,j,k,num,ans;int T[1002][1002];int Main () {ans=0;cin >> n;for (i=1;i<=n;i++) for (j=1;j<=n;j++ ) t[i][j]=0;cin >> m;for (i=1;i<=m;i++) {cin>>a>>b;t[a][b]=1;} for (k=1;k<=n;k++) for (i=1;i<=n;i++) for (j=1;j<=n;j++) if (t[i][k]&&t[k][j]) t[i][j]=1;    for (i=1;i<=n;i++) if (T[i][i]) cout << ' t ' << Endl;     else cout << ' F ' << Endl; return 0;}


Seriously reading the question seriously reading the question seriously

Freud algorithm Note output format


This article from the "Qhy of the" blog, reproduced please contact the author!

Codevs 1506 Messenger

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.