Week 8.8---8.14

Source: Internet
Author: User

It's a new week, eh.

8.8

Do CF

After a day's game, B thought well and complicated. Always count SG is wrong.

C is not understand how to deal with the first T-seconds inside not be 2 operation of the number of operations dropped

CF 366 Div2 c C-thor

To each node A queue, the queue is stored in the corresponding to the time it added,

In the 3 operation, you can maintain a position, if the last operation to T1 then this operation will only need to T1 to T2.

I didn't expect to throw every time as a thing into the queue.

1#include <stdio.h>2#include <string.h>3#include <stdlib.h>4#include <time.h>5#include <math.h>6#include <vector>7#include <map>8#include <Set>9#include <stack>Ten#include <queue> One#include <string> A#include <iostream> -#include <algorithm> - using namespacestd; the  -typedefLong LongLL; -typedef pair<int,int>PII; -typedef pair<Double,Double>PDD; + Const DoubleEPS = 1e-8; - Const intINF = (1<< -) -1; + Const intMAXN =300010; A intN,M,QUE[MAXN]; atqueue<int>Q[MAXN]; -  - voidsolve () { -     intOp,x,t =0, ans =0, pos =0; -memset (que,-1,sizeof(que)); -      for(inti =1; I <= m;i++){ inscanf"%d%d",&op,&x); -         if(OP = =1){ toQUE[++T] =x; + Q[x].push (t); -ans++; the         } *         Else if(OP = =2){ $              while(!Q[x].empty ()) {Panax Notoginseng                 intU =Q[x].front (); Q[x].pop (); -Que[u] =-1; theans--; +             } A         } the         Else{ +             inttop =min (t,x); -              for(inti = pos+1; I <= top;i++){ $                 if(Que[i] = =-1)Continue; $                 intv =Que[i]; - Q[v].pop (); -ans--; the             } -pos =Max (pos,top);Wuyi         } theprintf"%d\n", ans); -     } Wu } -  About intMain () { $scanf"%d%d",&n,&m); - solve (); -     return 0; -}
View Code

Week 8.8---8.14

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.