QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#404717#6786. Let's ChatLZDYTL 1ms3724kbC++14671b2024-05-04 15:13:142024-05-04 15:13:19

Judging History

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

  • [2024-05-04 15:13:19]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3724kb
  • [2024-05-04 15:13:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		long long n,m,x,y;
		cin>>n>>m>>x>>y;
		vector <long long> a(n);
		vector <long long> b(n);
		for(long long i=0;i<x;i++)
		{
			long long c,d;
			cin>>c>>d;
			for(long long i=c-1;i<d;i++) a[i]=1;
		}
		for(long long i=0;i<y;i++)
		{
			long long c,d;
			cin>>c>>d;
			for(long long i=c-1;i<d;i++) b[i]=1;
		}
		long long ans=0;
		long long t=0;
		for(long long 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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3724kb

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
Time 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: