QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#724440#7781. Sheep Eat Wolvesjuan_123#WA 0ms3608kbC++141020b2024-11-08 13:09:022024-11-08 13:09:02

Judging History

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

  • [2024-11-08 13:09:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3608kb
  • [2024-11-08 13:09:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define double long double
#define lowbit(x) (x&(-x))
const int inf = 1000000000;
int dis[2][105][105];
int X,Y,p,q;
bool check(int x,int y){
	if(x==0)return 1;
	return y-x<=p;
} 
signed main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> X >> Y >> p >> q;
	queue<pair<int,pair<int,int> > >q;
	for(int i =0;i<=X;i++)for(int j =0;j<=Y;j++)dis[0][i][j]=dis[1][i][j]=inf;
	q.push({0,{X,Y}});dis[0][X][Y]=0;
	while(!q.empty()){
		int tp = q.front().first,x = q.front().second.first,y = q.front().second.second;
		q.pop();
		for(int i =0;i<=x;i++){
			for(int j =0;j<=y;j++){
				if(i+j>p or !check(x-i,y-j))continue;
				int xx = X-(x-i),yy = Y-(y-j);
				if(dis[tp^1][xx][yy]>dis[tp][x][y]){
					dis[tp^1][xx][yy] = dis[tp][x][y]+1;
					q.push({tp^1,{xx,yy}});
				}
			}
		}
	} 
	int ans = inf;
	for(int i = 0;i<=Y;i++)ans = min(ans,dis[1][X][i]);
	if(ans == inf)ans = -1; 
	cout << ans << endl;
	return 0;
}/*
4 4 3 1 
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3608kb

input:

4 4 3 1

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3552kb

input:

3 5 2 0

output:

3

result:

wrong answer 1st numbers differ - expected: '5', found: '3'