QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#685856 | #7781. Sheep Eat Wolves | HanZhongBalls# | WA | 0ms | 3980kb | C++14 | 1.0kb | 2024-10-28 21:38:33 | 2024-10-28 21:38:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
#define N 105
#define eps 1e-10
#define F first
#define S second
#define INF 0x3f3f3f3f
#define mod 1000000007
int x,y,p,q,dp[N][N][2];
inline int d(int i,int j,int b){
if(dp[i][j][b]!=-1) return dp[i][j][b];
dp[i][j][b]=INF;
//printf("%d,%d,%d\n",i,j,b);
if(i<=p&&b==0){
dp[i][j][b]=1;
//printf("%d %d %d:%d\n",i,j,b,dp[i][j][b]);
return 1;
}
for(int a=0;a<=p;++a){
if(i-a<0) continue;
for(int c=0;a+c<=p;++c){
if(j-c<0||i-a>0&&j-c-(i-a)>q) continue;
dp[i][j][b]=min(dp[i][j][b],d(x-(i-a),y-(j-c),b^1)+1);
}
}
// printf("%d %d %d:%d\n",i,j,b,dp[i][j][b]);
return dp[i][j][b];
}
int main(){
int ans=1;
scanf("%d%d%d%d",&x,&y,&p,&q);
memset(dp,-1,sizeof(dp));
if(d(x,y,0)==INF){
puts("-1");
}else{
printf("%d\n",d(x,y,0));
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
input:
4 4 3 1
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
3 5 2 0
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
2 5 1 1
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
1 1 1 0
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3980kb
input:
3 3 1 1
output:
9
result:
wrong answer 1st numbers differ - expected: '7', found: '9'