QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#692297#7781. Sheep Eat Wolvesblhxzjr#WA 0ms3684kbC++231.1kb2024-10-31 14:17:212024-10-31 14:17:27

Judging History

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

  • [2024-10-31 14:17:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3684kb
  • [2024-10-31 14:17:21]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
signed main(){
	int x,y,q,p;
	cin >> x >> y >> p >> q;
	int flag=1;
	if(p>=x){
		cout << 1;
		return 0;
	}
	if(y>x+q){
		int cs=0;
		if(y>x+q+p){
			flag=0;
		}
		else{
			int duo=y-x-q;
			int kong=p-duo;
			int lang=(kong+1)/2+duo;
			int yang=kong/2;
			int zuolang=y-lang,zuoyang=x-yang;
			lang=lang-min(lang,yang+q);
			if(yang==0 && q==0){
				if(x-1<=p){
					cout << 5; 
				}
				else cout << -1;
				return 0;
			}
			yang=0;
			cs+=2;
			int cw=p-lang;
			if(zuolang==zuoyang+q){
				//先狼
				if(zuoyang>p){
					cs+=((zuoyang-p)+cw-1)/cw*2+1;
				}
				else cs++;
			}
			else{
				//先羊
				if(zuoyang>p){
					cs+=((zuoyang-p)-1+cw-1)/cw*2+1;
				}
				else cs++;
			}
//			cout << zuolang << " " << zuoyang << " " << p <<   " " << cw << "\n";
		}
		if(flag) cout << cs;
	}
	else{
		if(x+q>=y){
			//一次运走
			if(p>=x){
				cout << 1;
				return 0;
			}
			//一次运不走
			else{
				int duo=x+q-y;
				int zs=(y-duo)*2+duo;
				cout << (zs+p-1)/p;
				return 0;
			} 
		}
		else flag=0;
	}
	if(!flag) cout << -1; 
	return 0;
}

详细

Test #1:

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

input:

4 4 3 1

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

3 5 2 0

output:

5

result:

ok 1 number(s): "5"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3500kb

input:

2 5 1 1

output:

-1

result:

ok 1 number(s): "-1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

1 1 1 0

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

3 3 1 1

output:

5

result:

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