QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#575976#6786. Let's ChaticedAC ✓1ms3504kbC++231.1kb2024-09-19 17:43:472024-09-19 17:43:57

Judging History

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

  • [2024-09-19 17:43:57]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3504kb
  • [2024-09-19 17:43:47]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define endl '\n'
#define ll long long
#define pb push_back
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define noo cout<<"-1\n"
#define vi vector<int>
#define vl vector<long long>

#define int long long

typedef pair<int,int>PII;

//const int N = 
//const int MOD = 


void solve()
{
	int leng,k,n,m;cin>>leng>>k>>n>>m;
	vector<PII>a(n),b(m);
	for(auto &t:a)
		cin>>t.fi>>t.se;
	for(auto &t:b)
		cin>>t.fi>>t.se;
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	int res=0,j=0;
	for(int i=0;i<m;i++)
	{
		int s=0;
		while(j<n&&a[j].se<=b[i].se)
		{
			int t=a[j].se-max(a[j].fi,b[i].fi)+1;
			res+=max(0ll,t-k+1);
			j++;
			//cout<<res<<endl;
		}
		if(j<n&&b[i].se<a[j].se)
		{
			int t=b[i].se-max(a[j].fi,b[i].fi)+1;
			//cout<<b[i].se<<' '<<a[j].se<<endl;
			res+=max(0ll,t-k+1);
			//cout<<t<<endl;
		}
		 //cout<<res<<endl;
	}
	cout<<res<<endl;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	int T=1;
	cin>>T;
	while(T--)solve();
	return 0;
}


这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0
Accepted
time: 1ms
memory: 3504kb

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:

119342838
35153801
144883974
82675908
33074404
41458373
4138220
69656059
71436009
110675349

result:

ok 10 lines