QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#576011#6786. Let's ChatgqyangWA 1ms3704kbC++141.2kb2024-09-19 17:54:242024-09-19 17:54:26

Judging History

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

  • [2024-09-19 17:54:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3704kb
  • [2024-09-19 17:54:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
vector<PII> res;
const int N=110;
struct num{
	int a,b;
}q[N],w[N];
void solve()
{
	int n,m,x,y,m1;
	cin>>n>>m>>x>>y;
	m1=m-1;
	for(int i=0;i<x;i++)
	{
		cin>>q[i].a>>q[i].b;
	}
	for(int i=0;i<y;i++)
	{
		cin>>w[i].a>>w[i].b;
	}
	int l=0,r=0,k=0,cnt=0;
	for(int i=0;i<x;i++)
	{
		if(q[i].a>=w[k].a&&q[i].a<=w[k].b)
		{
			l=q[i].a;
			if(q[i].b<=w[k].b)
			{
				r=q[i].b;
				if(r-l>=m1)
				{
					cnt+=(r-l+2-m);
				}
				w[k].a=q[i].b;
			}
			else
			{
				r=w[k].b;
				if(r-l>=m1)
				{
					cnt+=(r-l+2-m);
				}
				q[i].a=w[k].b;
				i--;k++;
			}
		}
		else if(q[i].a<w[k].a)
		{
			if(q[i].b>=w[k].a&&q[i].b<=w[k].b)
			{
				l=w[k].a;r=q[i].b;
				if(r-l>=m1)
				{
					cnt+=(r-l+2-m);
				}
				w[k].a=q[i].b;
			}
			else if(q[i].b>w[k].a)
			{
				l=w[k].a;r=w[k].b;
				if(r-l>=m-1)
				{
					cnt+=(r-l+2-m);
				}
				q[i].a=w[k].b;
				i--;k++;
			}
		}
		else
		{
			i--;k++;
		}	
	}
	cout<<cnt<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int t;
	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

詳細信息

Test #1:

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

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: 3704kb

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
112236535

result:

wrong answer 10th lines differ - expected: '110675349', found: '112236535'