题目

链接:https://ac.nowcoder.com/acm/contest/11257/I
来源:牛客网

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K
Special Judge, 64bit IO Format: %lld

题目描述

There is a ring of numbers consisting of 111 to nnn sequentially. For every number iii (1≤i≤n−1)(1 \leq i \leq n - 1)(1≤i≤n−1), iii and i+1i+1i+1 are adjacent to each other. Particularly, nnn and 111 are adjacent. We use [l,r][l,r][l,r] to describe an interval on the ring. Formally, if l≤rl \leq rl≤r, then the interval [l,r][l,r][l,r] is equivalent to the set {l,l+1,…,r−1,r}{ l, l + 1, \ldots, r - 1, r }{l,l+1,…,r−1,r}. Otherwise, the interval [l,r][l,r][l,r] is equivalent to {l,l+1,…,n,1,…,r−1,r}{l,l+1,\ldots,n,1,\ldots,r-1,r}{l,l+1,…,n,1,…,r−1,r}.

Yukikaze has mmm non-intersecting intervals. She wants you to construct a set of intervals such that the intersection of them is the union of the mmm intervals that Yukikaze has. The intersection of the intervals is the set of integers that the intervals have in common.

输入描述:

The first line of the input contains a single integer T (1≤T≤1000)T\ (1 \leq T \leq 1000)T (1≤T≤1000), denoting the number of test cases.The first line of each test case contains two integers n (3≤n≤1000)n\ (3 \leq n \leq 1000)n (3≤n≤1000) and m (1≤m≤n)m\ (1 \leq m \leq n)m (1≤m≤n), denoting that the ring consists of numbers from 111 to nnn.Each of the next mmm lines contains two integers l,r (1≤l,r≤n)l,r\ (1 \leq l, r \leq n)l,r (1≤l,r≤n), denoting an interval Yukikaze has. It's guaranteed that the mmm intervals won't intersect with each other.

输出描述:

For each test case, if the answer doesn't exist, output −1-1−1 in a line. Otherwise, output an integer kkk indicating the number of intervals you construct in a line. Then output the kkk intervals in kkk lines. The number of intervals you used should never be less than one or greater than 200020002000. If there are multiple solutions, print any. Don't print any extra spaces at the end of each line.

示例1

输入

[复制](javascript:void(0)

2021牛客多校6 I Intervals on the Ring相关推荐

  1. LCS(2021牛客多校4)

    LCS(2021牛客多校4) 题意: 让你构造三个字符串s1,s2,s3,长度均为n,要求LCS(s1,s2)=a,LCS(s2,s3)=b,LCS(s1,s3)=c 题解: 先考虑三个串互相LCS为 ...

  2. 【2021牛客多校2】F-Girlfriend 计算几何

    2021牛客多校2-F F-Girlfriend 题目大意 给出四个点 A , B , C , D A, B, C, D A,B,C,D 另有两点 P 1 , P 2 P_1, P_2 P1​,P2​ ...

  3. K-Stack 2021牛客多校2

    链接:https://ac.nowcoder.com/acm/contest/11253/K 来源:牛客网 题目描述 ZYT had a magic permutation a1,a2,⋯ ,an a ...

  4. 2021牛客多校第八场补题 D-OR

    链接:https://ac.nowcoder.com/acm/contest/11259/D 来源:牛客网 题目描述 There are two sequences of length n−1n-1n ...

  5. 2021牛客多校第五场补题

    B-Boxes 链接:https://ac.nowcoder.com/acm/contest/11256/B 来源:牛客网 题目描述 There're nn_{}n​ boxes in front o ...

  6. 2021牛客多校9 - Cells(推公式+NTT)

    题目链接:点击查看 题目大意:初始时给出 nnn 个点,分别为 {(0,a0),(0,a1),⋯,(0,an)}\{(0,a_0),(0,a_1),\cdots,(0,a_n)\}{(0,a0​),( ...

  7. (2021牛客多校一)A.Alice and Bob(博弈)

    样例输入: 5 2 3 3 5 5 7 7 5 7 7 Bob Alice Bob Bob Alice 题意:有两堆石子,石子数目分别为n和m,Alice和Bob轮流进行以下操作: 从一堆石子中取出k ...

  8. 【多校训练】2021牛客多校5

    [前言] 很久没有时间整理题解了,补题和打游戏的时间居多(doge) 这场其实主要F出题人数据有锅,花太多时间了(赛后重测是一血),然后后面G想歪了爆搜剪枝没过,I的回滚莫队队友前一天写了结果今天写不 ...

  9. FFT ---- 2021牛客多校第一场 H Hash Function

    题目链接 题目大意: 解题思路: 首先我们知道任意两个数%seed\%seed%seed都不相同→\rightarrow→(aj−ai)%seed≠0(∀ai≤aj)(a_j-a_i)\%seed\n ...

  10. 线段树 ---- 2021牛客多校第一场 J Journey among Railway Stations [线段树维护区间可行性判断]

    题目链接 题目大意: 一段路上有 NNN 个点,每个点有一个合法时间段[ui,vi][u_i,v_i][ui​,vi​],相邻两个点有一个长度wiw_iwi​.有qqq次询问,每次询问,在 [ui,v ...

最新文章

  1. 北大美女学霸力压大神何恺明新作MAE!怒摘12个SOTA,灵感竟来自16年前CVPR论文...
  2. 微信公众号中网页安全提示去掉
  3. static,extern关键字作用?
  4. 自学python还是报班-零基础python自学还是报培训班?
  5. 你想建设一个能承受500万PV/每天的网站吗?如果计算呢?
  6. win10安装jdk1.8并配置环境变量_win10系统安装jdk13.02的环境变量配置
  7. 交流电机数字控制系统_敲黑板!新型变频调速控制系统对交流电动机设计的特殊要求...
  8. 转:min(x,y)高效算法
  9. 定制自己的Windows CE 5.0 ARM中文模拟器(转)
  10. 字体设计灵感|浓墨重彩!代表“墨”字设计案例
  11. 金九银十加薪季,测试题预热一波。
  12. 创业者都有一个共同的特质,他想做事,就立刻做
  13. win7下如何建立ftp服务器
  14. 先河系统为你讲解私有云服务器的优点
  15. 全网首发:Freeswitch会议房间增加标识
  16. mtkwin10驱动_Windows系统MTK手动安装驱动教程(Win10通用)
  17. HTML巩固练习之字体样式
  18. Mac OS 使用笔记
  19. WebSocket实战之一
  20. Python多线程爬虫,主播信息资料爬取采集

热门文章

  1. python实现论文查重系统_python 手把手教你基于搜索引擎实现文章查重
  2. 使用迅雷9.1.48从ftp服务器下载文件
  3. 基于深度学习的知识追踪研究进展 Research Advances in the Knowledge Tracing Based on Deep Learning
  4. 基于控制的角度无人机集群——目标追踪
  5. Linux查看mpp数据库地址,linux下打开.mpp文件(微软project)._操作系统_rainysia的专栏-CSDN博客...
  6. 利用googlemap查询经纬度
  7. 横图图片广告代码html,jQuery网页底部固定横幅图片广告代码
  8. 二维数组传参(二维数组作为函数参数)
  9. LWN: lockless编程模式——relaxed access和partial memory barrier
  10. zzzfun网站连接不上服务器,zzzfun网页版