QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#796245 | #7781. Sheep Eat Wolves | UESTC_DebugSimulator# | WA | 0ms | 3744kb | C++17 | 587b | 2024-12-01 15:05:21 | 2024-12-01 15:05:21 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=105,inf=1e9;
int x,y,p,q,f[N][N];
int dfs(int lx,int ly){
if(f[lx][ly])return f[lx][ly];
if(lx<=p)return 1;
f[lx][ly]=inf;
for(int bx=0;bx<=p;bx++){
int by=p-bx;
int nlx=lx-bx,nly=ly-by;
if(nly>nlx+q||nlx<0||nly<0)continue;
int rx=x-nlx,ry=y-nly;
if(rx&&ry>rx+q)nly+=ry-rx-q;
f[lx][ly]=min(f[lx][ly],dfs(nlx,nly)+2);
}
return f[lx][ly];
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>x>>y>>p>>q;
if(dfs(x,y)==inf)cout<<-1<<"\n";
else cout<<f[x][y]<<"\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3668kb
input:
4 4 3 1
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
3 5 2 0
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
2 5 1 1
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3612kb
input:
1 1 1 0
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'