QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#707198#7781. Sheep Eat Wolvesred_jiuCompile Error//C++233.1kb2024-11-03 15:05:222024-11-03 15:05:22

Judging History

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

  • [2024-11-03 15:05:22]
  • 评测
  • [2024-11-03 15:05:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

void solve()
{
    int x, y, p, q;
    cin >> x >> y >> p >> q;
    if(x <= p){
        cout<<1<<"\n";
        return ;
    }
    if(y - x - p > q){a#include <bits/stdc++.h>
using namespace std;

void solve()
{
    int x, y, p, q;
    cin >> x >> y >> p >> q;
    if(x <= p){
        cout<<1<<"\n";
        return ;
    }
    if(y - x - p > q){
        cout<<-1<<"\n";
        return ;
    }
    int ans = -1;
    for(int i=0;i<=ceil(1.0*y/p);i++){
        int lx , ly , rx , ry;
        lx = x , rx = 0;
        ly = y - i * p , ry = i * p;
        int tmp = i * 2;
        if(ry - p * 2 > q){
            break;
        }
        int opt = 0;
        while(lx){
            // 回
            if(opt & 1){
                int K2 = 0;
                if(rx && ry - rx > q){
                    K2 = min(ry - rx - q,p);
                }
                ry -= K2; ly += K2;
            }
            else{
                if(lx - ly >= p){
                    lx -= p; rx += p;
                }
                else{
                    int K1 = min(( p + q - ly + lx) / 2,p);
                    if(lx <= p) K1 = lx;
                    int K2 = p - K1;
                    rx += K1; ry += K2;
                    lx -= K1; ly -= K2;
                }
            }

            opt ^= 1;
            tmp ++ ;
            if(tmp == 10000) {
                tmp = -1; break;
            }
        }
        if(tmp == -1) continue;
        if(ans == -1) ans = tmp;
        else ans = min(ans , tmp);
    }
    cout << ans << "\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while(tt--)
        solve();
    return 0;
}

        cout<<-1<<"\n";
        return ;
    }
    int ans = -1;
    for(int i=0;i<=ceil(1.0*y/p);i++){
        int lx , ly , rx , ry;
        lx = x , rx = 0;
        ly = y - i * p , ry = i * p;
        int tmp = i * 2;
        if(ry - p * 2 > q){
            break;
        }
        int opt = 0;
        while(lx){
            // 回
            if(opt & 1){
                int K2 = 0;
                if(rx && ry - rx > q){
                    K2 = min(ry - rx - q,p);
                }
                ry -= K2; ly += K2;
            }
            else{
                if(lx - ly >= p){
                    lx -= p; rx += p;
                }
                else{
                    int K1 = min(( p + q - ly + lx) / 2,p);
                    if(lx <= p) K1 = lx;
                    int K2 = p - K1;
                    rx += K1; ry += K2;
                    lx -= K1; ly -= K2;
                }
            }

            opt ^= 1;
            tmp ++ ;
            if(tmp == 10000) {
                tmp = -1; break;
            }
        }
        if(tmp == -1) continue;
        if(ans == -1) ans = tmp;
        else ans = min(ans , tmp);
    }
    cout << ans << "\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while(tt--)
        solve();
    return 0;
}

Details

answer.code:12:24: error: stray ‘#’ in program
   12 |     if(y - x - p > q){a#include <bits/stdc++.h>
      |                        ^
answer.code: In function ‘void solve()’:
answer.code:12:23: error: ‘a’ was not declared in this scope
   12 |     if(y - x - p > q){a#include <bits/stdc++.h>
      |                       ^
answer.code:16:1: error: a function-definition is not allowed here before ‘{’ token
   16 | {
      | ^
answer.code:72:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   72 | int main()
      |         ^~
answer.code:72:9: note: remove parentheses to default-initialize a variable
   72 | int main()
      |         ^~
      |         --
answer.code:72:9: note: or replace parentheses with braces to value-initialize a variable
answer.code:73:1: error: a function-definition is not allowed here before ‘{’ token
   73 | {
      | ^