QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#248370#6439. Cloud Retainer's GameDeterminant#WA 267ms21376kbC++141.3kb2023-11-11 18:44:232023-11-11 18:44:23

Judging History

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

  • [2023-11-11 18:44:23]
  • 评测
  • 测评结果:WA
  • 用时:267ms
  • 内存:21376kb
  • [2023-11-11 18:44:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;const int N=2e5+7;
int n,m,cnt,cnt2,h,z1[N],z2[N],x[N],c[N],d[N],f[N];
vector<pair<int,int> >G[N],G2[N];
void sol(){
	scanf("%d%d",&h,&n);h+=h;cnt=0;d[cnt2=1]=0;
	for(int i=1,y;i<=n;++i){
		scanf("%d%d",&x[i],&y);c[++cnt]=x[i];
		z1[i]=(1ll*h+(x[i]-y)%h)%h,z2[i]=(x[i]+y)%h;
		d[++cnt2]=z1[i];d[++cnt2]=z2[i];
	}
	scanf("%d",&m);
	for(int i=n+1,y;i<=m+n;++i){
		scanf("%d%d",&x[i],&y);c[++cnt]=x[i];
		z1[i]=(1ll*h+(x[i]-y)%h)%h,z2[i]=(x[i]+y)%h;
		d[++cnt2]=z1[i];d[++cnt2]=z2[i];
	}
	sort(c+1,c+cnt+1);cnt=unique(c+1,c+cnt+1)-c-1;
	sort(d+1,d+cnt2+1);cnt2=unique(d+1,d+cnt2+1)-d-1;
	for(int i=1;i<=n;++i)
	G[lower_bound(c+1,c+cnt+1,x[i])-c].push_back(
	{lower_bound(d+1,d+cnt2+1,z1[i])-d,lower_bound(d+1,d+cnt2+1,z2[i])-d});
	for(int i=n+1;i<=n+m;++i)
	G2[lower_bound(c+1,c+cnt+1,x[i])-c].push_back(
	{lower_bound(d+1,d+cnt2+1,z1[i])-d,lower_bound(d+1,d+cnt2+1,z2[i])-d});
	for(int i=1;i<=cnt2;++i)f[i]=-1e9;f[1]=0;
	for(int i=1;i<=cnt;++i){
		for(auto j:G[i])f[j.first]=f[j.second]=max(f[j.first],f[j.second]);
		for(auto j:G2[i])f[j.first]++,f[j.second]++;
		G[i].clear();G2[i].clear();
	}
	int ans=0;for(int i=1;i<=cnt2;++i)ans=max(ans,f[i]);printf("%d\n",ans);
}
int main(){int t;scanf("%d",&t);while(t--)sol();return 0;}

详细

Test #1:

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

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: 267ms
memory: 21376kb

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
1
2
1
3
2
0
2
4
6
1
2
0
0
1
2
1
1
0
1
0
0
2
1
1
3
2
3
3
2
1
2
0
1
5
1
1
1
0
1
3
1
2
3
3
3
2
1
0
3
1
2
2
0
4
1
1
0
1
2
2
2
1
1
1
1
2
3
2
2
2
1
1
3
1
3
0
0
3
4
5
1
1
1
1
1
0
2
0
0
3
0
2
1
1
1
0
3
2
1
3
4
3
2
2
4
2
4
2
1
2
1
0
1
3
0
3
0
2
1
0
2
5
1
2
2
1
0
1
3
0
2
3
1
4
2
2
0
2
3
2
0
0
3
1
1
1
1
3
2
...

result:

wrong answer 5501st numbers differ - expected: '265', found: '170'