QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#594080#7786. Graft and TransplantargtargWA 1ms3524kbC++201.2kb2024-09-27 18:57:522024-09-27 18:57:53

Judging History

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

  • [2024-09-27 18:57:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3524kb
  • [2024-09-27 18:57:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pii pair<int, int>
void solve();

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    // cin >> T;
    while (T--)solve();
    return 0;
}
const int mod = 1e9 + 7;


void solve() {
    int x,y,p,q;
    cin>>x>>y>>p>>q;
    if(x<=p) {
        cout<<1<<endl;
        return;
    }
    vector<vector<int>>dp(x+1,vector<int>(y+1,1e4));
    dp[x][y]=-1;
    int ans=1e4;
    for(int i=x;i>=0;i--) {
        for(int j=y;j>=0;j--) {
            int a=x-i,b=y-j;
            if(i+q<j&&i!=x||a+q<b&&a!=0)continue;
            // if(i==2&&j==4)cout<<dp[i][j]<<endl;
            if(i<=p)ans=min(ans,dp[i][j]+2);
            for(int xx=0;xx<=i;xx++) {
                for(int yy=0;yy<=j;yy++) {
                    if(xx>p-yy)continue;
                    dp[i-xx][j-yy]=min(dp[i-xx][j-yy],dp[i][j]+2);
                }
            }
        }
    }
    ans=min(*min_element(dp[0].begin(),dp[0].end()),ans);
    if(p/2+p>=x&&x+p+q>=y) {
        ans=min(5ll,ans);
    }
    if(ans!=1e4)cout<<ans<<endl;
    else cout<<-1<<endl;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3524kb

input:

4
1 2
2 3
3 4

output:

3

result:

wrong answer 1st words differ - expected: 'Alice', found: '3'