Zzuli 1877 Clam Wei Cleaning the classroom

Source: Internet
Author: User

1877: Clam Cleans the classroom
Description

now know that there are a total of n room, the total number of Clam Wei has m players, the coach made M-sign, each sign written two number l,r (l<=r), the person to be [l,r] to clean the classroom all over. Because Clam is captain and he's lazy, He knew in advance what was written on all m-signatures through some sort of trade, and he was able to control which sign he drew by some sort of magic. A classroom was cleaned once, so clam wanted to know which signs he smoked without cleaning the classroom and would not be noticed by the coach, that the range he had drawn was cleaned by others.

Clam Wei was called by the coach to clean the computer room, training team has a lot of room, there are many players, now they have to draw a lottery to decide who cleans which classroom.Input

The first behavior is an integer T (1<=t<=20), which represents the number of data groups. The first row of each group of data n,m (1<=n,m<=100000), followed by M-line, two numbers per line l,r (1<=l<=r<=n).

Output

Each set of data output a K, indicating how many signed to meet the requirements of the clam, the next line of output K number, these signed number, subscript starting from 1.

Sample Input3 the514556 89 Ten5 63 61 11 12 22 23 33 3Ten 31 42 66 TenSample Output22561 2 3 4 5 60
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <queue>5#include <vector>6 using namespacestd;7 Const intmaxn=2e5+7;8 intA[MAXN],B[MAXN],C[MAXN];9 structnode{intL,r;} P[MAXN];Tenvector<int>ans; One intMain () A { -     intT; -scanf"%d",&T); the      while(t--) -     { - ans.clear (); -Memset (A,0,sizeof(a)); +Memset (c,0,sizeof(c)); -         intn,m; +scanf"%d%d",&n,&m); A          for(intI=0; i<m;i++) at         { -             intx, y; -scanf"%d%d",&x,&y); -a[x]++,a[n+y]--; -P[i].l=x,p[i].r=y; -         } in         intCnt=0; -          for(intI=1; i<=n;i++) to         { +cnt+=A[i]; -b[i]=CNT; thecnt+=a[n+i]; *         } $          for(intI=1; i<=n;i++)Panax Notoginseng         { -             if(b[i]>1) c[i]=c[i-1]+1; the             Elsec[i]=c[i-1]; +         } A          for(intI=0; i<m;i++) the         { +             if(c[p[i].r]-c[p[i].l-1]==p[i].r-p[i].l+1) - Ans.push_back (i); $         } $         intlen=ans.size (); -printf"%d\n", Len); -         if(len) the         { -              for(intI=0; i<len-1; i++)Wuyiprintf"%d", ans[i]+1); theprintf"%d\n", ans[len-1]+1); -         } Wu     } -     return 0; About}

Zzuli 1877 Clam Wei Cleaning the classroom

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.