QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#796245#7781. Sheep Eat WolvesUESTC_DebugSimulator#WA 0ms3744kbC++17587b2024-12-01 15:05:212024-12-01 15:05:21

Judging History

你现在查看的是最新测评结果

  • [2024-12-01 15:05:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3744kb
  • [2024-12-01 15:05:21]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'