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