A problem is not AC.

Source: Internet
Author: User

Title Description
MLM Organization GPLT The purpose of the MLM organization is "A willing heart", they recently in the implementation of a magnificent purpose is "a willing heart", they recently in the implementation of a magnificent purpose is "a willing heart", they recently in the implementation of a magnificent purpose is "a willing heart", they recently in the implementation of a magnificent The purpose is "a willing heart", they recently in the implementation of a magnificent purpose is "a willing heart", they recently in the implementation of a magnificent purpose is "a willing heart", they recently in the implementation of a magnificent purpose is "a willing heart", they recently in the implementation of a magnificent purpose is "a willing heart", Their recent implementation of a magnificent purpose is "a willing heart", their recent implementation of a grand purpose is "a willing heart", their recent implementation of a magnificent purpose is "a willing heart", they recently in the implementation of a magnificent purpose is "a willing heart", they recently in the implementation of a magnificent The aim is "a willing heart", who recently implemented a grand N-man program to plan for people, to plan people, to build a scientific and effective intelligence system. In other words, build a scientific and effective intelligence system. In other words, build a scientific and effective intelligence system. In other words, build a scientific and effective intelligence system. In other words, build a scientific and effective intelligence system. In other words, build a scientific and effective intelligence system. In other words, build a scientific and effective intelligence system. In other words, build a scientific and effective intelligence system. In other words, build a scientific and effective intelligence system. In other words, the GPLT organization would like to build an organization that hopes to build an organization that would like to build one by an organization that hopes to build an individual and a number of one-way private telephone individuals and several one-way privately-owned telephones by the organization and several unidirectional private telephone personal and several unidirectional private phone individuals and several A one-way private telephone line composed of intelligence, and make a series of requirements to meet. These are divided into two categories: a line-composed intelligence, and make a series of requirements to meet. These are divided into two categories: a line-composed intelligence, and make a series of requirements to meet. These are divided into two categories: a line-composed intelligence, and make a series of requirements to meet. These are divided into two categories: a line-composed intelligence, and make a series of requirements to meet. These are divided into two categories: a line-composed intelligence, and make a series of requirements to meet. These are divided into two categories: a line-composed intelligence, and make a series of requirements to meet. These are divided into two categories: a line-composed intelligence, and make a series of requirements to meet. These are divided into two categories: a line-composed intelligence, and make a series of requirements to meet. These are divided into two categories: a line-composed intelligence, and make a series of requirements to meet. These are divided into two categories: a line-composed intelligence, and make a series of requirements to meet. These are divided into two categories: a line-composed intelligence, and make a series of requirements to meet. These are divided into two categories: a line-composed intelligence, and make a series of requirements to meet. These are divided into two categories: A line of intelligence that makes it possible to meet a range of requirements. These are divided into two categories:
① from a person through an individual through 1 or more phone lines or multi-line or multi-line or multi-phone lines or multiple phone lines can be contacted to contact the first person.
② from a person through an individual through 1 or more phone lines or multi-line or multi-line or multiple phone lines or multi-phone lines can not contact the first contact to the B person.
Now the head of the head of the GPLT organization, Gluo, asks you to help give an intelligence that satisfies all the requirements, or tells him to ask you for help with an intelligence that satisfies all of the requirements, or to tell him that it asks you to give an intelligence to meet all the requirements, or to tell him that Ask your help to provide an intelligence to meet all the requirements, or tell him that this asks you to give a help to meet all the requirements of the intelligence, or tell him this ask you to help give a meet all the requirements of the intelligence, or tell him this ask you to help give a meet all the requirements of the intelligence, or tell him this Ask your help to provide an intelligence to meet all the requirements, or tell him that this asks you to give a help to meet all the requirements of the intelligence, or tell him this ask you to help give a meet all the requirements of the intelligence, or tell him this ask you to help give a meet all the requirements of the intelligence, or tell him this Ask your help to provide an intelligence to meet all the requirements, or tell him that you can help to give a meet all the requirements of the intelligence, or tell him that such a intelligence is impossible to exist. The kind of intelligence is impossible to exist. The kind of intelligence is impossible to exist. The kind of intelligence is impossible to exist. The kind of intelligence is impossible to exist. The kind of intelligence is impossible to exist.
Input format
Each test point contains several sets of data, each of which contains several sets of data, each of which contains several sets of data, each of which contains several sets of data, each of which contains several sets of data, ending with EOF, for each group of data: For each set of data: For each group of data Data:
The first line, the first line, 1 integer N, indicates the number of intelligence. , which represents the number of intelligence. , which represents the number of intelligence. , which represents the number of intelligence. , which represents the number of intelligence.
The second line of the second row of 1 integer M, indicating that the number of ① class requirements, the next ① class requirements, the next ① class requirements, the next ① class requirements, the next ① class requirements, the next ① class requirements, the next M-line per row per 2 integer A, B.
Line m+3 1 integer T, representing the number of ② class requirements, representing the number of ② class requirements, representing the number of ② class requirements, indicating the number of ② class requirements, the number of ② class requirements, indicating the number of ② classes required next to the next T line each line every 2 integers a, B.
Output format
For each set of data in the test point, for each set of data in the test point, for each set of data in the test point, for each set of data in the test point, for each group of data in the test point, if there is no such intelligence, if there is no such information, output if there is no such intelligence, the output without such an intelligence, Output if there is no such intelligence, output if there is no such intelligence, output if there is no such intelligence, output if there is no such intelligence, output if there is no such intelligence, output No. Otherwise in the first line output otherwise in the first row output otherwise in the first row output YES, the number of phone lines in the second line of output intelligence in the second line of the output intelligence in the number of telephone lines in the second line of output intelligence in the number of telephone lines in the next line of the output the number of telephone lines in the intelligence The number of telephone lines in the second line of output intelligence is in the second line of the output intelligence in the number of telephone lines in the second line of the output intelligence in the number of telephone lines in the second line of the output of the telephone line number P, Next, Next, Next, the next P line per 2 integer description telephone line integer description phone line integer description of telephone A line integer describes a telephone line with an integer describing the telephone line. Due to resource availability due to resource constraints, requirements are limited and p<=n+m+t are required.
Sample input
3
2
1 2
2 3
1
3 1
3
2
1 2
2 3
1
1 3
Sample output
YES
2
1 2
2 3
NO
Sample input and Output 2
See the Test folder under the Examination questions folder under the See Questions folder under the Gplt.in/ans.
Data scope and conventions
For data of 20%, 1≤n≤100.
For data of 60%, 1≤n≤25000.

For data of 100% data, 1≤n, M, T≤100000,1≤a, b≤n,a≠b, the output requirements of the required output of the p<=n+m+t output.



First of all, the first step must be to the requirements of M directly connected to the edge, perceptual. It will have a small effect on the second operation. Then there is the fast-forward graph connectivity. However, there seems to be nothing less than the practice of n^2 ... (It seems as if the mark was just a bit of pressure afterwards). Then, in order to avoid exploding the memory to divide a block ... is also a bit metaphysical.

However, I obviously don't think n^2 can get through ... So I wrote a very metaphysical memory of the complexity of the time space is very unfathomable .... The 4th point ran for 1.5 seconds. Fifth point ran for 5 seconds, 6th point 144 seconds ... However, the size of these three points is virtually the same. Other points (including larger data) are within 1 seconds ... It seems to be beyond the expectations of my mess.

But I was 0 in the beginning ... Because many sets of data is a pit ... Ordinary people do no when the break directly ... Then continue reading the data will be confused ... Day dog ...


#include <cstdio> #include <cmath> #include <ctime> #include <string> #include <cstring> #include <cstdlib> #include <iostream> #include <algorithm> #include <set> #include <sta ck> #include <queue> #include <vector> #include <map> #include <list> #define PB push_back #def ine lb Lower_bound #define SQR (x) (x) * (x) #define LOWBIT (x) (x) & (-X) #define ABS (x) ((x) > 0? (x): (-(x)) #define FORUP (I,A,B) for (Int. i= (a); i<= (b); i++) #define Fordown (I,A,B) for (int i= (a); i>= (b); i--) #de  Fine LS (A, a) (((a) + (b)) << 1) #define RS (A, a) (((a) + (b)) >> 1) #define GETLC (a) ch[(a)][0] #define GETRC (a)  Ch[(a)][1] #define MAXN 100005 #define MAXM 100005 #define INF 1070000000 using namespace std;  typedef long Long LL;    typedef unsigned long long ull;      Template<class t> inline void read (t& num) {num = 0; bool F = True;char ch = getchar (); while (Ch < ' 0 ' ||      Ch > ' 9 ') {if (ch = = '-') F = false;ch = GetChar ();}      while (Ch >= ' 0 ' && ch <= ' 9 ') {num = num * + CH-' 0 '; ch = GetChar ();} num = f?  Num:-num; } int out[100];  Template<class t> inline void write (T X,char ch) {if (x==0) {Putchar (' 0 '); putchar (ch); return;}  if (x<0) {Putchar ('-'); x=-x;}  int num=0;  while (x) {out[num++]= (x%10); X=X/10;} Fordown (i,num-1,0) putchar (out[i]+ ' 0 '); Putchar (CH); }/*==================split line==================*/int n,m,t;map<int,bool> f[maxn];vector<int> G1[MAXN ],g2[maxn];vector<int> s;vector<int> g[maxn];int cnt=0;bool vis[maxn];int id[maxn];void dfs1 (int x) {vis[x    ]=1;        for (int i=0;i<g1[x].size (); i++) {int v=g1[x][i]; if (!vis[v]) {DFS1 (v);}} S.PB (x);    } void Dfs2 (int x) {id[x]=cnt;       for (int i=0;i<g2[x].size (); i++) {int v=g2[x][i]; if (!id[v]) dfs2 (v);}}     BOOL Work (int x,int y) {if (F[x].count (y)!=0) {return f[x][y];} Forint i=0;i<g[x].size (); i++) {int v=g[x][i];  F[x][y]=work (V,y);        if (f[x][y]==true) return true; } return false;}    void ClearAll () {Forup (i,1,n) {f[i].clear (); G1[i].clear (); G2[i].clear ();} Forup (i,1,cnt) g[i].clear (); S.clear ();}   int main () {freopen ("gplt.in", "R", stdin); Freopen ("Gplt.out", "w", stdout);    while (scanf ("%d%d", &n,&m)!=eof) {cnt=0; ClearAll ();  Forup (i,1,m) {int x, y; read (x); Read (y); G1[X].PB (y); G2[Y].PB (x);}  memset (vis,0,sizeof (Vis)), Forup (i,1,n) {if (!vis[i]) DFS1 (i);  } for (int i=s.size () -1;i>=0;i--) {int v=s[i]; if (!id[v]) {cnt++; DFS2 (v);}}   Forup (i,1,n) for (int j=0;j<g1[i].size (); j + +) {int v=g1[i][j]; F[id[i]][id[v]]=1;} Forup (i,1,cnt) for (Map<int,bool>::iterator J=f[i].begin (); J!=f[i].end (); j + +) {int v=j->first; G[I].PB (v);}   Read (t); bool Flag=1;forup (i,1,t) {int x,y;read (x); Read (y);  if (flag==0) continue;        if (Id[x]==id[y]) {flag=0;printf ("no\n");    Continue;} BoOL ans=work (Id[x],id[y]);     if (ans) {flag=0;printf ("no\n"); continue;}  } if (flag==1) {printf ("yes\n");     Write (m, ' \ n ');       Forup (x,1,n) for (int y=0;y<g1[x].size (); y++) {int v=g1[x][y];   Write (x, "); write (v, ' \ n '); }}}return 0;  }


A problem is not AC.

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.