有多组数据,对于每组数据: 第一行有两个整数n,m(1≤n,m≤100000) 接下来m行,代表m个操作,格式如题目所示。
对于每个2号操作,输出一个整数,表示查询的结果。
10 10 1 1 2 0 1 3 4 1 2 1 4 1 5 6 2 2 1 6 1 7 8 1 2 3 8 1 8 10 3 2 1 10 2 3 8
2 3 2 4 3
题解: 把每个颜色包含的区间存起来 只需判断两个区间是否有交集即可
判断两区间是否有交集:
if(max(a1, a2) < min(b1, b2))
{ return "有交集"}
else
{ return "无交集"}
需要用vector进行区间保存,
#include
#include
#include
#include
using namespace std;
struct note
{
vectorl,r;
} e[100];
int main()
{
int n,m,x,y,z,w;
while(~scanf("%d%d",&n,&m))
{
for(int i=0; i<=65; i++)
{
e[i].l.clear();
e[i].r.clear();
}
for(int i=0; i