A big battle of elective courses

Source: Internet
Author: User

Title Description

Watching the freshman will come, the original freshman became a study of uncle.

Small C again for the new semester to choose the question of the busy up .... Gradually he found a problem: when he wanted to learn the "computer network" class, the system told him that he had to learn "discrete mathematics" to learn the subject.

Therefore, we call the "discrete Mathematics" is the "computer network" must study subjects. Now it is known that the course selection system collects the order relationship of many subjects, but this system has some faults, some information may be inaccurate, so please help small C to determine whether the information is wrong, first of all the information error refers to "subject X is the required subject of account y , and the subject y is also the required subject of account X , the account X is a required subject for account y , and account y is the account Z Must-study subjects, subject Z is the required subject of account X " This is also wrong.

InputSection1Line:1an integerT, which represents the number of groups of dataT (1 <= T <= 5)

Next the T Group data is in the following format:
line 1 :2 integers,n,m. N indicates the total number of courses and the course number is 1..N. M represents the number of sequential relationships. 1 <= N <= 100,000.1 <= M <= 500,000
line 2..m+1 : 2 integers per line, a,b. Indicates that course A is a pre-set course for course B .

OutputSection1..Trows: Per line1string, if the group information is correct, the output"Correct", if the group information is incorrect, the output"Wrong".

Sample input
22 21 22 13 21 21 3
Sample output
Wrongcorrect

#include <stdio.h> #include <string.h> #define N 500001int Main () {int t,n,m,i,x,y;int a[n];scanf ("%d",& T); while (t--) {int flag=1;  scanf ("%d%d", &n,&m);  memset (A,0,sizeof (a));  for (i=0;i<=m-1;i++)  {   scanf ("%d%d", &x,&y);   a[x]=1;  }  for (i=1;i<=n;i++)  {    if (a[i]==0)    {     flag=0;     break;    }  }  if (flag==0)  {    printf ("correct\n");  }  else  {    printf ("wrong\n");}  }  return 0;}




Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Big Battle of elective course

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.