QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#735563#7781. Sheep Eat WolvesSuhy#WA 0ms1652kbC++171008b2024-11-11 20:44:082024-11-11 20:44:10

Judging History

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

  • [2024-11-11 20:44:10]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1652kb
  • [2024-11-11 20:44:08]
  • 提交

answer

#include<cstdio>
int x,y,p,q;//sheep,wolf,seat,,safe right
int gans(){
    y-=q;
    if(y<=0)return 2*((x+p-1)/p)-1;
    if(x<=p)return 1;
    if(x-p+y-p<=p)return 3;
    if(y-p<=x&&(p>>1)+p>=x)return 5;
    int P=p;
    if(y-q>x)p-=y-q-x,y-=y-q-x;
    if(y-p>x)return -1;
    if(p<=0)return -1;
    int ans=0;
    if(x<y){
        ++ans;
        if(y-q==x){
            y-=q;
            x-=(p-q)>>1;
            y-=(p-q)>>1;
            q=0;
        }else{
            int k=y-x;
            y-=k;q-=k;
            x-=(p-k)>>1;
            y-=(p-k)>>1;
            if((p-k)&1)--y,--q;
        }
    }
    while(x){
        ++ans;
        if(x<=P)x=0;
        else{
            x-=p>>1;
            y-=p>>1;
            if((p&1)){
                if(x>y)--x,++q;
                else if(q>0)--y,--q;
            }
        }if(ans>1000)return -1;
    }
    return 2*ans-1;
}
int main(){
    scanf("%d%d%d%d",&x,&y,&p,&q);
    printf("%d",gans());
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 4 3 1

output:

3

result:

ok 1 number(s): "3"

Test #2:

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

input:

3 5 2 0

output:

5

result:

ok 1 number(s): "5"

Test #3:

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

input:

2 5 1 1

output:

-1

result:

ok 1 number(s): "-1"

Test #4:

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

input:

1 1 1 0

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

3 3 1 1

output:

7

result:

ok 1 number(s): "7"

Test #6:

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

input:

3 3 2 1

output:

3

result:

ok 1 number(s): "3"

Test #7:

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

input:

10 9 1 10

output:

19

result:

ok 1 number(s): "19"

Test #8:

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

input:

15 20 2 5

output:

27

result:

ok 1 number(s): "27"

Test #9:

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

input:

18 40 16 7

output:

5

result:

ok 1 number(s): "5"

Test #10:

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

input:

60 60 8 1

output:

27

result:

ok 1 number(s): "27"

Test #11:

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

input:

60 60 8 4

output:

27

result:

ok 1 number(s): "27"

Test #12:

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

input:

60 60 8 8

output:

27

result:

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