微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决第 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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。