QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#576047#6786. Let's Chatzerocloud01AC ✓0ms3632kbC++201.0kb2024-09-19 18:05:102024-09-19 18:05:10

Judging History

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

  • [2024-09-19 18:05:10]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3632kb
  • [2024-09-19 18:05:10]
  • 提交

answer

#include<bits/stdc++.h>
#define Start cin.tie(0), cout.tie(0), ios::sync_with_stdio(false)
#define PII pair<int,int> 
#define x first
#define y second
#define ull unsigned long long
#define ll long long
using namespace std;

struct edge
{
	int x,y,z;
	bool operator < (const edge &i)	const
	{
		return(x == i.x ? (y == i.y ? z < i.z : y < i.z) : x < i.x);
	}
};

const int M = 1000000007;
const int N = 1e5 + 10;

void func(void);

signed main(void)
{
	Start;
	int _ ; cin >> _;
	while(_--)	func();
	return 0;
}

void func(void)
{
	int n,m,x,y,ans = 0;
	cin >> n >> m >> x >> y;
	vector<PII> a(x);
	vector<PII> b(y);
	for(auto &i : a)	cin >> i.x >> i.y;
	for(auto &i : b)	cin >> i.x >> i.y;
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	for(int i=0;i<x;++i)
	{
		for(int j=0;j<y;++j)
		{
			int res = 0;
			if(a[i].y < b[j].x || a[i].x > b[j].y)	continue;
			res += min(a[i].y,b[j].y) - max(a[i].x,b[j].x) + 1;
			ans += (res >= m ? res-m+1 : 0);
		}
	}
	
	cout << ans << '\n';
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0ms
memory: 3632kb

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