第 1034 行:字符 34:运行时错误:将非零偏移量 8 应用于空指针 (stl_vector.h) 摘要:UndefinedBehaviorSanitizer:undefined-behavior

class Solution {
public:
    static bool nonDec(vector<int> a,vector<int> b){
        return ((a[0]*a[1])>(b[0]*b[1]));
    };
    
    int maxHeight(vector<vector<int>>& cuboids) {
        int n=cuboids.size();
        int rotLength=3*n;
        vector<vector<int>> rot(rotLength);
        //rot 0->length//1->width//2->height
        int index=0;
        for(int i=0;i<n;i++){
            rot[index][2]=cuboids[i][2];
            rot[index][0]=cuboids[i][0];
            rot[index][1]=cuboids[i][1];
            index++;
            
            rot[index][2]=cuboids[i][0];
            rot[index][1]=max(cuboids[i][1],cuboids[i][2]);
            rot[index][1]=min(cuboids[i][1],cuboids[i][2]);
            index++;
            
            
            rot[index][2]=cuboids[i][1];
            rot[index][1]=max(cuboids[i][0],cuboids[i][2]);
            rot[index][1]=min(cuboids[i][0],cuboids[i][2]);
            index++;
        }
        n=3*n;
        sort(rot.begin(),rot.end(),nonDec);
        vector<int> msh;
        for(int i=0;i<n;i++){ msh[i]=rot[i][2];}
        for(int i=1;i<n;i++){
            for(int j=0;j<i;j++){
                if(rot[i][1]<=rot[j][1] && rot[i][0]<=rot[j][0] && rot[i][2]<=rot[j][2] && msh[i]<msh[j]+rot[i][2]){
                    msh[i]=msh[j]+rot[i][2];
                }
            }
        }
        int maxValue=0;
        for(int i=0;i<n;i++){
            if(msh[i]>maxValue){
                maxValue=msh[i];
            }
        }
        return maxValue;
    }
};

问题链接:https://leetcode.com/problems/maximum-height-by-stacking-cuboids/ 错误:第 1034 行:字符 34:运行时错误:将非零偏移量 8 应用于空指针 (stl_vector.h) 总结:UndefinedBehaviorSanitizer:undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h :1043:34

a436084592 回答:第 1034 行:字符 34:运行时错误:将非零偏移量 8 应用于空指针 (stl_vector.h) 摘要:UndefinedBehaviorSanitizer:undefined-behavior

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/74586.html

大家都在问