QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#679026#7781. Sheep Eat Wolvessurenjamts#WA 1ms4864kbC++171.6kb2024-10-26 16:41:522024-10-26 16:41:52

Judging History

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

  • [2024-10-26 16:41:52]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4864kb
  • [2024-10-26 16:41:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
int x, y, p, q;
bool check(int i, int j, int k){
	// if(i == 3 && j == 3 && k == 1) cout << "entered\n";
	 if(i < 0 || i > x || j < 0 || j > y) return 0;
	 if(j > i + q && k == 1 && i > 0) return 0;
	 if(y - j > x - i + q && k == 0 && i < x) return 0;
//	 if(i == 3 && j == 3 && k == 1) cout << "correct\n";
	 return 1;
}
struct node{
	int s, w, side;
	node(int s, int w, int side) : s(s), w(w), side(side) { }
};

vector<node> adj[105][105][5];
int d[105][105][5];
signed main(){
//	x = 3, y = 5, p = 2, q = 0;
	cin >> x >> y >> p >> q;
	for(int i = 0; i <=x; i++){
		for(int j = 0; j <= y; j++){
			  d[i][j][0] = d[i][j][1] = 1e15;
		      for(int a = 0; a <= i; a++){
		      	  for(int b = 0; b <= j; b++){
		      	  	   adj[i][j][0].emplace_back(i - a, j - b, 1);
				  }
			  }
			  for(int a = 0; a <= x - i; a++){
			  	  for(int b = 0; b <= y - j; b++){
			  	  	   adj[i][j][1].emplace_back(i + a, j + b, 0);
					}
			  }
		}
	}
	
	queue<node> q;
	d[x][y][0] = 0;
	q.push({x, y, 0});
	while(!q.empty()){
		auto it = q.front(); q.pop();
		for(auto next : adj[it.s][it.w][it.side]){
			if(d[it.s][it.w][it.side] + 1 < d[next.s][next.w][next.side]){
				 d[next.s][next.w][next.side] = d[it.s][it.w][it.side] + 1;
				 q.push(next);
			}
		}
	}

    int ans = 1e9;
    for(int j = 0; j <= y; j++){
    	ans = min(ans, d[0][j][1]);
	}
	if(ans > 1e8) cout << "-1\n";
	else cout << ans << '\n';
	
	
	
	
	   
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 4864kb

input:

4 4 3 1

output:

1

result:

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