QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#554866 | #8558. Grid Game | PhantomThreshold# | WA | 11ms | 3716kb | C++20 | 2.9kb | 2024-09-09 16:48:04 | 2024-09-09 16:48:05 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int maxn = 21000;
int n;
vector<int>V[500];
int f[2][105];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int Tcase; cin>>Tcase;
while(Tcase--)
{
for(int i=1;i<=200;i++) V[i].clear();
cin>>n;
for(int i=1;i<=n;i++)
{
int x,y; cin>>x>>y;
V[x+y].push_back(x-y);
}
/* for(int i=1;i<=100;i++)
{
l[i]=0,r[i]=i; //number of -1
}
int ok=1;
for(int i=1;i<=200;i++)
{
for(auto c:V[i])
{
if(c==0) ok=0;
if(c>0)
{
int ui= (i+1)/2;
for(int j=1;j<=ui;j++) r[j]=min(r[j], (c+1)/2-1 );
}
if(c<0)
{
int ui= (i+1)/2;
//j-l[j]<=(-c+1)/2-1
for(int j=1;j<=ui;j++) l[j]=max(l[j], j-( (-c+1)/2-1 ) );
}
}
}*/
int now=0;
memset(f,0,sizeof f);
for(int i=0;i<=101;i++) f[now][i]=1;
for(int i=200;i>=0;i--)
{
int ui=i/2;
now=!now;
if(i%2==0)
{
for(int j=0;j<=ui;j++)
{
// -1 +1
int x=j, y=ui-x;
int ok=1;
for(auto c:V[i])
{
if(c==0) { ok=0;break; }
else if(c>0)
{
if(x*2>=c) { ok=0;break; }
}
else
{
if(y*2>=-c) { ok=0;break; }
}
}
if(ok) f[now][j]=f[!now][j];
else f[now][j]=0;
}
}
else
{
for(int j=0;j<=ui;j++)
{
// -1 +1
int x=j, y=ui-x;
int num=0;
for(auto c:V[i])
{
if(c>=0)
{
if(x*2>=c) num++;
}
else
{
if(y*2>=-c) num++;
}
}
if(num==0) f[now][j]= f[!now][j]|f[!now][j+1];
else if(num==1) f[now][j]= f[!now][j]&f[!now][j+1];
else if(num>=2) f[now][j]=0;
}
}
}
if(f[now][0]) cout<<"Yes\n";
else cout<<"No\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
input:
3 1 3 3 2 2 0 1 2 4 2 0 2 3 1 6 5 2
output:
No Yes Yes
result:
ok 3 token(s): yes count is 2, no count is 1
Test #2:
score: -100
Wrong Answer
time: 11ms
memory: 3716kb
input:
1000 1 3 1 5 2 1 1 4 3 1 2 1 5 4 8 0 2 0 1 0 2 0 2 2 1 2 1 0 2 1 0 4 4 3 6 3 0 1 6 1 1 2 7 8 3 1 3 1 5 0 5 4 0 5 1 0 4 5 4 5 3 2 2 0 2 2 0 2 5 4 1 0 8 2 6 1 3 6 2 4 7 8 7 0 5 7 3 2 3 3 1 0 1 0 1 1 6 1 1 0 1 1 0 0 1 1 0 0 1 4 3 0 2 5 4 2 6 3 9 3 4 1 5 0 1 0 6 3 6 2 0 3 5 1 5 1 3 4 6 0 4 2 6 2 3 0 9 1...
output:
Yes Yes No Yes Yes No No Yes No No No Yes No Yes No No No Yes Yes No No No No Yes No Yes No Yes No No No No No Yes No No No No No No No No No Yes No No No Yes No No Yes No No Yes No No No No No No No No No No Yes No No No No No Yes No No Yes Yes No Yes No No No No No No No No No No No No No Yes No Y...
result:
wrong answer expected NO, found YES [44th token]