Eighth multi-school field: Graph Theory degree

Source: Internet
Author: User

HDU 4948

I am sorry for this question. After reading this question, I thought it was quite simple.

At the beginning, I thought about Topology Sorting, and then I thought about it ...... This is the reverse order of topological sorting, and then we find that it is quite watery ......

If you want to develop a city, you must have another city as the prerequisite for its development. That is, if the City U-> W is connected, you must develop the city w, the premise is that u is already a developed city. That's not very easy.

That is to say, the first city to be developed is the city with the highest degree of output, because u-> W can see that the largest degree of output is sorted in ascending order.

Oh, it's a pity, because I saw no one handed in this question, and then did not dare to tell my teammates what I wanted, and I didn't even think about it ...... Then, I missed the opportunity to enter the first version of the project. It was really broken down by the first echelon ......

#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<map>#include<queue>#include<set>#include<cmath>#include<bitset>#define mem(a,b) memset(a,b,sizeof(a))#define lson i<<1,l,mid#define rson i<<1|1,mid+1,r#define llson j<<1,l,mid#define rrson j<<1|1,mid+1,r#define INF 0x7fffffff#define maxn 11010using namespace std;typedef long long ll;typedef unsigned long long ull;char s[500][505];struct abc{    int i,out;    bool operator<(const abc &a)const    {        return out>a.out;    }}a[501];int main(){    //freopen("1.txt","r",stdin);    int n,i,j;    while(scanf("%d",&n)&&n)    {        for(i=0;i<n;i++)            scanf("%s",s[i]),a[i].i=i,a[i].out=0;        for(i=0;i<n;i++)            for(j=0;j<n;j++)                if(s[i][j]=='1')                    a[i].out++;        sort(a,a+n);        printf("%d",a[0].i+1);        for(i=1;i<n;i++)            printf(" %d",a[i].i+1);        puts("");    }    return 0;}


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.