QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#185320#6439. Cloud Retainer's Gamebeckham_of_laiwuWA 339ms9388kbC++141.5kb2023-09-21 21:13:472023-09-21 21:13:48

Judging History

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

  • [2023-09-21 21:13:48]
  • 评测
  • 测评结果:WA
  • 用时:339ms
  • 内存:9388kb
  • [2023-09-21 21:13:47]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;

const int N = 1e5 + 5;

#define LL long long

struct qwq{
	LL x,y,c;
};
qwq a[N * 2];

bool cmp(qwq a,qwq b)
{
	if(a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}

int T,n,m;
LL H;

int main()
{
	scanf("%d",&T);
	while(T --)
	{
		scanf("%lld",&H);
		H *= 2;
		scanf("%d",&n);
		for(int i = 1;i <= n;i ++)
		{
			scanf("%lld%lld",&a[i].x,&a[i].y);
			a[i].c = 0;
		}
		scanf("%d",&m);
		for(int i = n + 1;i <= n + m;i ++)
		{
			scanf("%lld%lld",&a[i].x,&a[i].y);
			a[i].c = 1;
		}
		sort(a + 1,a + n + m + 1,cmp);
		map <LL,LL> mp;
		mp.clear();
		mp[0] = 0;
		LL ans = 0;
		for(int i = 1;i <= n + m;i ++)
		{
			if(a[i].c == 1)
			{
				LL k = (a[i].x + a[i].y) % H;
				if(mp.find(k) != mp.end()) mp[k] ++;
				ans = max(ans,mp[k]);
				LL _k = (H - a[i].y + a[i].x) % H;
				if(k == _k) continue;
				if(mp.find(_k) != mp.end()) mp[_k] ++;
				ans = max(ans,mp[_k]);
			}
			else
			{
				LL k = (a[i].x + a[i].y) % H;
				LL _k = (H - a[i].y + a[i].x) % H;
				if(mp.find(k) == mp.end() && mp.find(_k) == mp.end()) continue;
				LL now = max(mp[k],mp[_k]);
				ans = max(ans,now);
				mp[k] = now; mp[_k] = now;
			}
		}
		printf("%lld\n",ans);
	}
	return (0 ^ 0);
}
/*
1
10
19
2 4
2 8
8 3
8 4
8 7
2 7
2 6
1 5
3 2
6 4
2 1
4 5
2 5
7 1
4 7
5 7
2 2
8 6
8 1
12
5 1
4 8
5 2
6 1
3 6
1 1
1 7
7 2
5 6
6 8
1 2
3 5
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
4
3
1 1
2 2
6 2
4
3 1
3 3
5 1
7 3
3
1
4 2
3
1 1
6 2
9 1

output:

3
3

result:

ok 2 number(s): "3 3"

Test #2:

score: -100
Wrong Answer
time: 339ms
memory: 9388kb

input:

5503
10
19
2 4
2 8
8 3
8 4
8 7
2 7
2 6
1 5
3 2
6 4
2 1
4 5
2 5
7 1
4 7
5 7
2 2
8 6
8 1
12
5 1
4 8
5 2
6 1
3 6
1 1
1 7
7 2
5 6
6 8
1 2
3 5
10
5
9 5
10 7
6 6
5 7
1 3
9
6 8
8 8
6 4
2 9
5 4
4 2
10 9
2 3
2 1
7
1
4 3
14
4 6
6 1
2 1
7 6
2 3
4 4
5 3
6 5
1 4
3 4
3 2
6 2
8 6
8 2
6
6
5 2
5 1
3 1
2 3
7 4
5 5
3
...

output:

2
2
3
1
3
2
2
2
4
6
3
2
0
2
2
2
2
3
2
2
0
1
4
3
2
3
4
3
3
2
2
3
0
3
5
3
2
1
3
1
3
4
2
3
3
3
3
1
1
3
3
5
2
2
4
1
2
0
3
3
4
3
2
2
2
2
3
3
2
3
2
1
1
4
2
3
1
0
4
4
5
1
1
2
1
3
2
3
0
0
4
2
3
3
2
2
0
3
3
4
3
4
4
2
2
4
2
4
2
3
3
1
0
4
3
0
4
0
2
2
1
4
5
1
3
2
2
0
1
3
1
3
3
2
4
2
2
1
2
3
3
2
1
3
2
2
3
1
3
3
...

result:

wrong answer 2nd numbers differ - expected: '1', found: '2'