2799 University Rankings Enhanced Edition

Source: Internet
Author: User

2799 University Rankings Enhanced Edition

 

time limit: 1 s space limit: 128000 KB title level: Diamonds Diamond Solving Title Description Description

University rankings are now very popular. Search online for information on all aspects of Chinese university rankings.

we know , usually in a university by many different " " (professional) composition, such as Computer Science (abbreviated as cs ee fls ), and so on. In a university, one of its majors may be in the domestic row, but other professions are unknown. As a result, most university rankings have a detailed ranking of different majors.

But the sheer volume of information is not a serious problem: which university is better? Fortunately, Dr Beaubourg proposed a new concept of " absolute better ", which would allow the problem to be partially resolved.

To better illustrate Dr. Beaubourg's new concept, let's give an example:

Assuming there are now three universities: x University, y University, z University. Each university has three majors: cs , ee , fls And the three major international recognized rankings of the three universities are as follows:

CS rank: x>y>z ( x>y means x cs professional than y good)

EE Rankings:x>z>y

FLS ranking:z>x>y

Obviously, every major at X University is better than y University, so x University is definitely better than y University . Using this concept we can compare the merits of some universities.

Now Dr. Beaubourg has a complete list of different majors in various universities, and he wants to find out suchKa University (U1,U2,U3...,uk),Uimust be better thanUj(i<j) good.

Can you tell Dr. Beaubourg the maximum value of K?

Enter a description input Description

The first line has two integers n,M(0<n,m≤100), indicating that there are n universities and M Major.

The nextMLine,Part I(1<=i<=m) line hasNThe number of the universityUj(1≤j≤n,1≤uj≤n), on behalf of sectionIa professionalNUniversity Rankings (the more in the previous rankings).

outputs description output Description

The output file should be one line, which is the maximum value of the K value. No extra spaces are required.

Sample Input to sample

3 3

1 2 3

1 3 2

3 1 2

Sample Output Sample outputs

2

data size & Hint

0<n,m≤100

Category labels  Tags Click here to expandOpen questions Graph theory

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Exercises

First time with object-oriented writing

Pretreatment

Rank ORDER BY Total ranking

Find the longest ascending subsequence

Complete

(For specific reasons, self-repair of the brain)

AC Code:

#include <cstdio>#include<algorithm>using namespacestd;Const intn= the;classnode{ Public:        voidModifyintIintx) {s=s+x;g[i]=x;} intAtinti) {returng[i];} intSum () {returns;} int operator[](inti) {returnAt (i);} Private:        intG[n],s;} A[n];intN,m,ans,f[n];BOOLCMP (node X,node y) {returnX.sum () >y.sum ();}BOOLCompare (node X,node y) { for(intI=1; i<=m;i++)if(X[i]>y[i])return 0; return 1;}intMain () {scanf ("%d%d",&n,&m);  for(intI=1, v;i<=m;i++){         for(intj=1; j<=n;j++) {scanf ("%d",&v);        A[v].modify (I,J); }} sort (a+1, a+n+1, CMP);  for(intI=1; i<=n;i++) f[i]=1;  for(intI=1; i<=n;i++){         for(intj=1; j<i;j++){            if(compare (A[i],a[j])) {F[i]=max (f[i],f[j]+1); }        }    }     for(intI=1; i<=n;i++) ans=Max (ans,f[i]); printf ("%d", ans); return 0;}

 

2799 University Rankings Enhanced Edition

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.