QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#634449#7781. Sheep Eat WolvesCCFWA 0ms3896kbC++141.2kb2024-10-12 17:20:502024-10-12 17:20:51

Judging History

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

  • [2024-10-12 17:20:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3896kb
  • [2024-10-12 17:20:50]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define fs first
#define sc second
#define pb push_back
#define SZ(X) (int)((X).size())
#define lb(i) ((i)&-(i))
#define cl(i) memset(i,0,sizeof(i))
const int N=6.1e3;
int solve(int x,int y,int p,int q,int a,int b){
    int side=0,nw=0,cnt=0;
    for(;x>0;side^=1){
        cnt++;
        if(side==0){
            if(x<=p-nw)return cnt;
            while(nw<p){
                while(nw<p&&y-x<q)x--,a++,nw++;
                if(nw<p)y--,b++,nw++;
            }
            if(y-x>q)return 1e9;
            nw=0;
        }
        if(side==1){
            //x>0
            while(a>0&&nw<p&&b-a>q)b--,y++,nw++;
            //assert(a==0||b-a<=q);////
            if(!(a==0||b-a<=q))return 1e9;
            nw=0;
        }
    }
    return cnt;
}
int main(){
    int x,y,p,q;
    cin>>x>>y>>p>>q;
    int mn=solve(x,y,p,q,0,0);
    for(int i=1;i<=p*2&&y-i>=0;i++){
        if(y-i-x<=q)mn=min(mn,solve(x,y-i,p,q,0,i)+2+2*(i>p));
        //if(mn<1e9)cerr<<i<<" "<<mn<<"\n";
    }
    if(mn>=1e9)puts("-1");
    else printf("%d\n",mn);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 4 3 1

output:

3

result:

ok 1 number(s): "3"

Test #2:

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

input:

3 5 2 0

output:

5

result:

ok 1 number(s): "5"

Test #3:

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

input:

2 5 1 1

output:

9

result:

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