Harbin University of Science and Technology sixth session program design team I-team

Source: Internet
Author: User
Tags stdin acer

/*I've done a queue-jumping problem before, and this is like moving from back to forward .*/#include<iostream>#include<stdio.h>#include<algorithm>#include<string.h>#include<vector>#defineN 600000using namespacestd;structnode{intx, Y, Z //For each operation, z indicates that the operation is not validnode () {} node (intAintBintc) {x=A; Y=b; Z=C; }};vector<node>V;vector<int>W;intt,n,m;intx, y, zintDone[n];//indicates that the current number has not been manipulatedintA[n];//That means those people were added.voidinit () {memset (A,0,sizeofa);    V.clear (); V.push_back (Node (0,0,0));    W.clear (); memset (Done,0,sizeofDone );}intMain () {//freopen ("C:\\users\\acer\\desktop\\in.txt", "R", stdin);scanf"%d",&t); //cout<<t<<endl;     while(t--) {init (); scanf ("%d%d",&n,&m); //cout<<n<< "" <<m<<endl;         for(intI=0; i<m;i++) {scanf ("%d%d",&x,&y); V.push_back (node (x, Y,1)); }         for(intI=v.size ()-1; i>=0; i--)        {            if(V[I].Z)//This operation can be done            {                if(v[i].x==3) V[v[i].y].z=0; Else if(v[i].x==1)                {                    if(done[v[i].y]==0) {A[V[I].Y]=1; DONE[V[I].Y]=1; }                }                Else if(v[i].x==2)                {                    if(done[v[i].y]==0) {A[V[I].Y]=0; DONE[V[I].Y]=1; }                }            }        }         for(intI=1; i<=n;i++)        {            //cout<<a[i]<< "";            if(a[i]==1) {w.push_back (i); //cout<<i<< "";            }        }        //cout<<endl;printf"%d\n", W.size ());  for(intI=0; I<w.size (); i++) printf ("%d", W[i]); printf ("\ n"); }    return 0;}
/*need a can write simulation of teammates, online and so very urgent inexplicable re, all can consider the place is considered*//*do not operate first, run all the operations to see which of the operations are valid and which are invalid*/#include<iostream>#include<stdio.h>#include<algorithm>#include<string.h>#include<vector>#defineN 600000using namespacestd;structnode{intx, Y, Z //For each operation, z indicates that the operation is not validnode () {} node (intAintBintc) {x=A; Y=b; Z=C; }};vector<node>V;vector<int>W;intt,n,m;intx, y, zintA[n];//That means those people were added.voidRecallintX//x is the x operation to undo{    if(x<1|| X>v.size ())return; //cout<<x<<endl;    if(v[x].x!=3)//if you want to undo the 1, number 2nd operation.{v[x].z^=1;//Undo This operation//If it's been revoked, it's off the pipe.        return ; }    Else{v[x].z^=1;//Undo This operationRecall (V[X].Y);//continue to recursively undo the next Operation//If it's been revoked, it's off the pipe.    }}voidinit () {memset (A,0,sizeofa);    V.clear (); V.push_back (Node (0,0,0)); W.clear ();}intMain () {//freopen ("C:\\users\\acer\\desktop\\in.txt", "R", stdin);scanf"%d",&t); //cout<<t<<endl;     while(t--) {init (); scanf ("%d%d",&n,&m); //cout<<n<< "" <<m<<endl;         for(intI=0; i<m;i++) {scanf ("%d%d",&x,&y); //cout<<x<< "" <<y<<endl;            if(x==1) {V.push_back (node (x, Y,1)); }            Else if(x==2) {V.push_back (node (x, Y,1)); }            Else if(x==3) {V.push_back (node (x, Y,1)); //cout<< "**********" <<endl;recall (y); //cout<< "**********" <<endl;            }        }         for(intI=0; I<v.size (); i++)        {            if(v[i].x!=3)//only 1, number 2nd operation can be            {                if(V[I].Z)//This operation is valid                {                    //cout<<v[i].x<< "" <<v[i].y<<endl;                    if(v[i].x==1) {A[V[I].Y]=1; }                    Else if(v[i].x==2) {A[V[I].Y]=0; }                }            }        }         for(intI=1; i<=n;i++)        {            //cout<<a[i]<< "";            if(a[i]==1) {w.push_back (i); //cout<<i<< "";            }        }        //cout<<endl;printf"%d\n", W.size ());  for(intI=0; I<w.size (); i++) printf ("%d", W[i]); printf ("\ n"); }    return 0;}

Harbin University of Science and Technology sixth session program design team I-team

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.