QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#735525#7781. Sheep Eat WolvesSuhy#WA 0ms1648kbC++17977b2024-11-11 20:31:252024-11-11 20:31:26

Judging History

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

  • [2024-11-11 20:31:26]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1648kb
  • [2024-11-11 20:31:25]
  • 提交

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)--x,--q;
        }
    }
    while(x){
        ++ans;
        if(x<=P)x=0;
        else{
            x-=p>>1;
            y-=p>>1;
            if((p&1)){
                if(q)--y,--q;
                else --x,++q;
            }
        }
    }
    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: 1464kb

input:

4 4 3 1

output:

3

result:

ok 1 number(s): "3"

Test #2:

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

input:

3 5 2 0

output:

5

result:

ok 1 number(s): "5"

Test #3:

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

input:

2 5 1 1

output:

-1

result:

ok 1 number(s): "-1"

Test #4:

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

input:

1 1 1 0

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

3 3 1 1

output:

9

result:

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