QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#625717#7003. Rikka with Minimum Spanning Treesucup-team5071#Compile Error//C++201.8kb2024-10-09 20:38:162024-10-09 20:38:16

Judging History

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

  • [2024-10-09 20:38:16]
  • 评测
  • [2024-10-09 20:38:16]
  • 提交

answer

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

int n;
int h[55];
int difh[55];
double d[55];

double dp[55][55][2];

bool ava(double x1,double x2,double y1,double y2){
    double minx = min(x1,x2);
    double maxx = max(x1,x2);
    double miny = min(y1,y2);
    double maxy = max(y1,y2);
    return miny <= minx && maxx <= maxy;
}

bool gmin(double &x,double y){
    if (x > y) {x = y;return true;}
    return false;
}

void dfs(int x,int y,int k){
    if (y-x == 1) return ;

    double dh;


    if (k == 0){
        
        if (ava(h[x],h[x+1],h[y-1],h[y])) {
            dh = abs(h[x+1]-h[x]);
            double nxt = dp[x][y][k] + d[x] + dh/difh[y-1]*d[y-1];
            if (dp[x+1][y][0] == -1) dp[x+1][y][0] = nxt;
            else {
                gmin(dp[x+1][y][0],nxt);
                dfs(x+1,y,0);
            }

            dh = abs(h[y-1] - h[x]);
            nxt = dh/difh[y-1]*d[y-1] + dh/difh[x]*d[x];
            if (dp[x][y-1][1] == -1) dp[x][y-1][1] = nxt;
            else {
                gmin(dp[x][y-1][1],nxt);
                dfs(x,y-1,1);
            } 
        }
        
    } else {
        if (ava())
    }

}

void solve(){

    cin >> n;
    for (int i = 0; i <= n; ++i){
        cin >> h[i];
    }
    if (n == 1){
        cout << 0 << "\n";
        return ;
    }
    for (int i = 0; i <= n; ++i){
        for (int j = 0; j <= n; ++j){
            dp[i][j][0] = -1;
            dp[i][j][1] = -1;
        }
    }
    for (int i = 0; i < n; ++i){
        int dif = abs(h[i+1]-h[i]);
        d[i] = sqrt(1+dif*dif);
        difh[i] = dif;
    }
    dfs(0,n,0);
    dfs(0,n,1);

}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);
    int T;cin>>T;
    while(T--)solve();
}

Details

answer.code: In function ‘void dfs(int, int, int)’:
answer.code:51:16: error: too few arguments to function ‘bool ava(double, double, double, double)’
   51 |         if (ava())
      |             ~~~^~
answer.code:11:6: note: declared here
   11 | bool ava(double x1,double x2,double y1,double y2){
      |      ^~~
answer.code:52:5: error: expected primary-expression before ‘}’ token
   52 |     }
      |     ^