QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#692521 | #7781. Sheep Eat Wolves | 123456zmy# | WA | 0ms | 3748kb | C++17 | 1.1kb | 2024-10-31 14:39:14 | 2024-10-31 14:39:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int dp[2][101][101];
int vis[2][101][101];
int main()
{
int X,Y,p,q;
cin>>X>>Y>>p>>q;
function<int(int,int,int)>f=[&](int x,int y,int s)
{
// cerr<<x<<" "<<y<<" "<<s<<endl;
if(x==0)return 0;
if(vis[s][x][y])return dp[s][x][y];
vis[s][x][y]=1;
int&ans=dp[s][x][y];
ans=1e9;
if(s==0)
{
for(int i=0;i<=min(p,x);i++)
{
for(int j=0;j<=min(p-i,y);j++)
{
if(x-i+p<y-j)continue;
ans=min(ans,f(x-i,y-j,1)+1);
}
}
}
else
{
for(int i=0;i<=min(p,X-x);i++)
{
for(int j=0;j<=min(p-i,Y-y);j++)
{
if(X-x-i+p<Y-y-j)continue;
ans=min(ans,f(x+i,y+j,0)+1);
}
}
}
return dp[s][x][y]=ans;
};
int ans=f(X,Y,0);
printf("%d\n",ans<1e9?ans:-1);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3732kb
input:
4 4 3 1
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
3 5 2 0
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
2 5 1 1
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
1 1 1 0
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3732kb
input:
3 3 1 1
output:
9
result:
wrong answer 1st numbers differ - expected: '7', found: '9'