QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#625083 | #6439. Cloud Retainer's Game | wwww22# | RE | 0ms | 3596kb | C++20 | 1.2kb | 2024-10-09 17:23:31 | 2024-10-09 17:23:31 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define fo(i,a,b) for(ll (i)=(a);(i)<=(b);(i)++)
#define fd(i,a,b) for(ll (i)=(a);(i)>=(b);(i)--)
using namespace std;
const int N=1e5+10;
int h,n,m;
int f[2*N];
struct node
{
int a,b,k;
}p[2*N];
bool cmp(node x,node y)
{
if(x.a!=y.a)return x.a<y.a;
return x.b<y.b;
}
void solve()
{
cin>>h;
for(int i=0;i<2*h+5;i++)
{
f[i]=-1e9;
}
f[0]=0;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>p[i].a>>p[i].b;
p[i].k=1;
}
cin>>m;
for(int i=n;i<n+m;i++)
{
cin>>p[i].a>>p[i].b;
p[i].k=2;
}
sort(p,p+n+m,cmp);
for(int i=0;i<n+m;i++)
{
if(p[i].k==1)
{
f[(p[i].a+p[i].b)%(2*h)]
=max(f[(p[i].a+p[i].b)%(2*h)],
f[((p[i].a-p[i].b)%(2*h)+2*h)%(2*h)]);
f[((p[i].a-p[i].b)%(2*h)+2*h)%(2*h)]
=max(f[(p[i].a+p[i].b)%(2*h)],
f[((p[i].a-p[i].b)%(2*h)+2*h)%(2*h)]);
}
if(p[i].k==2)
{
f[(p[i].a+p[i].b)%(2*h)]++;
f[((p[i].a-p[i].b)%(2*h)+2*h)%(2*h)]++;
}
}
int ans=0;
for(int i=0;i<2*h;i++)
{
ans=max(ans,f[i]);
}
cout<<ans<<"\n";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int T=1;
cin>>T;
while(T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
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
Runtime Error
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 ...