QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#404703#6786. Let's ChatLZDYML 0ms3512kbC++14589b2024-05-04 14:56:342024-05-04 14:56:35

Judging History

你现在查看的是最新测评结果

  • [2024-05-04 14:56:35]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:3512kb
  • [2024-05-04 14:56:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n,m,x,y;
		cin>>n>>m>>x>>y;
		int a[n]={0};
		int b[n]={0};
		for(int i=0;i<x;i++)
		{
			int c,d;
			cin>>c>>d;
			for(int i=c-1;i<d;i++) a[i]=1;
		}
		for(int i=0;i<y;i++)
		{
			int c,d;
			cin>>c>>d;
			for(int i=c-1;i<d;i++) b[i]=1;
		}
		int ans=0;
		int t=0;
		for(int i=0;i<n;i++)
		{
			if(a[i]==1&&b[i]==1)
			{
				t++;
			}
			else
			{
				if(t>=m)
				{
					ans+=t-m+1;
				}
				
				t=0;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3512kb

input:

2
10 3 3 2
1 3
5 8
10 10
1 8
10 10
5 3 1 1
1 2
4 5

output:

3
0

result:

ok 2 lines

Test #2:

score: -100
Memory Limit Exceeded

input:

10
978378582 3619603 47 74
479986 5351489
5420308 7962369
11344514 15240567
28052230 34309090
69930493 71370103
96064381 113030999
131487830 167306026
201120250 210905551
215581108 218116928
239370726 250969994
251488779 259451325
264979602 268998475
277209414 278821999
294684099 297838279
300870315...

output:


result: