QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#575975#6786. Let's Chatzerocloud01WA 1ms3592kbC++201.5kb2024-09-19 17:43:412024-09-19 17:43:42

Judging History

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

  • [2024-09-19 17:43:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3592kb
  • [2024-09-19 17:43:41]
  • 提交

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());
	int i=0,j=0;
	while(i<x && j<y)
	{
		int res = 0;
		while(a[i].y < b[j].x)
		{
			++i;
			if(i >= x)	break;
		}
		while(a[i].x > b[j].y)
		{
			++j;
			if(j >= y)	break;
		}
		if(i >= x || j >= y)	break;
		if(a[i].y <= b[j].y)
		{
			if(a[i].x <= b[j].x)	res = a[i].y - b[j].x + 1;
			else res = a[i].y - a[i].x + 1;
			// cout << i << ' ' << j << ' ' << res << '\n';
			++i;
		}
		else if(a[i].y >= b[j].y)
		{
			if(a[i].x >= b[j].x)	res = (b[j].y - a[i].x + 1);
			else res = b[j].y - b[i].x + 1;
			// cout << i << ' ' << j << ' ' << res << '\n';
			++j;
		}
		if(i > x || j > y)	break;
		// cout << i << ' ' << j << ' ' << res << '\n';
		ans += (res >= m ? res-m+1 : 0);
	}
	cout << ans << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
Wrong Answer
time: 1ms
memory: 3484kb

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:

-1404509277
35153801
892856105
666503897
1511022951
154255892
47149824
1448919887
-1763612861
110675349

result:

wrong answer 1st lines differ - expected: '119342838', found: '-1404509277'