QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#657826#7781. Sheep Eat Wolvesxiaoxiao__WA 1ms3728kbC++201.0kb2024-10-19 15:32:172024-10-19 15:32:22

Judging History

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

  • [2024-10-19 15:32:22]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3728kb
  • [2024-10-19 15:32:17]
  • 提交

answer

#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<cstring>
#include<algorithm>
#define fi first
#define se second
using ll=long long;
using namespace std;
typedef pair<int,int>pii;
const int N=109;
int ans=9;
int x,y,p,q;
int dfs(int now,int x1,int y1,int x2,int y2){
    if(x1<=p)return 1;
    for(int i=p;i>=0;i--){
    //cout<<x1<<x2<<y1<<y2<<endl;
        int sheep=x1-i;
        int yun=0;
        if(sheep+q<y1)yun=y1-sheep-q;
        if(yun+i>p)continue;
        int sheep2=x2+i;
        int yun2=0;
        if(sheep2!=0&&sheep2+q<y2+yun)yun2=y2+yun-sheep2-q;
        if(yun2>p||(i==0&&yun==yun2))continue;
        int res=dfs(now+1,sheep,y1-yun+yun2,sheep2,y2+yun-yun2);
        if(res>0)return res+2;
    }
    return -1;
}
void Silverwolf(){
    cin>>x>>y>>p>>q;
    int ans=dfs(1,x,y,0,0);
    cout<<ans<<endl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int T;cin>>T;while(T--)
    Silverwolf();
    return 0;
}

詳細信息

Test #1:

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

input:

4 4 3 1

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

3 5 2 0

output:

5

result:

ok 1 number(s): "5"

Test #3:

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

input:

2 5 1 1

output:

-1

result:

ok 1 number(s): "-1"

Test #4:

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

input:

1 1 1 0

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

3 3 1 1

output:

-1

result:

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