QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#754796#7781. Sheep Eat WolvesStar_s#WA 0ms3640kbC++14937b2024-11-16 15:49:172024-11-16 15:49:18

Judging History

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

  • [2024-11-16 15:49:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3640kb
  • [2024-11-16 15:49:17]
  • 提交

answer



#include<bits/stdc++.h>
using namespace std;

int main()
{
	int sheep_lef, wolf_lef, sheep_rig = 0, wolf_rig = 0, n, k;
	int cnt = 0, all = sheep_lef;
	while (true) {
		int i;
		if (sheep_rig == all) {
			cout << cnt << endl;
			break;
		}
		for (i = n; i >= 0; i--) {
			int a = sheep_lef - i, b = wolf_lef - (n - i);
			if (b != 0 && a != 0 && b - a > k) {
				continue;
			}
			else {
				sheep_lef = a, wolf_lef = b, sheep_rig += i, wolf_rig += (n - i);
				break;
			}
		}
		if (i == -1) {
			cout << -1 << endl;
			break;
		}
		cnt++;
		if (sheep_rig == all) {
			cout << cnt << endl;
			break;
		}
		for (i = 0; ; i++) {
			int b = wolf_rig - i;
			if (sheep_rig != 0 && b != 0 && b - sheep_rig > k) {
				continue;
			}
			else {
				wolf_rig = b;
				wolf_lef += i;
                break;
			}
		}
		cnt++;
		if (sheep_rig == all) {
			cout << cnt << endl;
			break;
		}
	}
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3640kb

input:

4 4 3 1

output:

0

result:

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