求问 神奇CE

P1253 扶苏的问题

llamn @ 2024-09-11 21:35:32

本地编译能过,洛谷上显示

g++: 编译器内部错误:CPU time limit exceeded signal terminated program cc1plus
Please submit a full bug report, with preprocessed source (by using -freport-bug).
参阅 <https://gcc.gnu.org/bugs/> 以获取指示。

或者:

Nothing is compiled: CPU_TIME exceeds.

以及更离谱的:

g++: 编译器内部错误:CPU time limit exceeded signal terminated program cc1plus
请提交一份完整的错误报告,
如有可能请附上经预处理后的源文件。
参阅 <https://gcc.gnu.org/bugs/> 以获取指示。

代码:

#include <bits/stdc++.h> 
#define _eggy_ using 
#define _party_ namespace
#define pf printf
#define sf scanf
#define TLE() while(1);
#define un unsigned
#define mod(x) ((x))
#define eggy (1145141919810ll)
#define _eggy() (((p1==p2) && (p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2))?EOF:*p1++)
_eggy_ _party_ std;char *p1,*p2,buf[100000];long long read();
int n,m,i,j,k,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30;

long long v,ans,a[1000100];
template<un char ceng> // dzpd<i> 可以记录 1 << i  
struct dzpd
{
    struct dzpd <ceng-1> ls,rs;
    int l,r;
    long long maxx = 0ll,mini_add = 0ll,mini_eq = eggy;
    void bd(int bdl, int bdr)
    {
        l = bdl, r = bdr;
        if (bdl == bdr)
        {
            maxx = a[bdl];
            return;
        }
        ls.bd(bdl,(bdl+bdr)>>1);
        rs.bd(((bdl+bdr)>>1)+1,bdr);
        maxx = max(ls.maxx , rs.maxx);
    }
    void miniworld()
    {
        if (mini_eq != eggy)
        {
            ls.maxx = mini_eq, ls.mini_add = 0ll, ls.mini_eq = mini_eq;
            rs.maxx = mini_eq, rs.mini_add = 0ll, rs.mini_eq = mini_eq;
            mini_eq = eggy;
        }
        ls.maxx = ls.maxx + mini_add;
        ls.mini_add += mini_add; 
        rs.maxx = rs.maxx + mini_add;
        rs.mini_add += mini_add; 
        mini_add = 0ll;
    }
    void add() //编号被模版吃了,l,r留在全局变量里,成功实现无参函数! 
    {
        if ((t1 <= l) && (r <= t2))
        {
            mini_add += v;
            maxx += v; // 由于全局修改l~r,所以即使v<0,也只能直接加 
            return;
        }miniworld();
        if (t2 <= ls.r) ls.add();
        else if (t1 >= rs.l) rs.add();
        else {ls.add(); rs.add();}
        maxx = max(ls.maxx , rs.maxx);
    }
    void eq()
    {
        if ((t1 <= l) && (r <= t2))
        {
            mini_eq = v;
            mini_add = 0;
            maxx = v;
            return;
        }miniworld();
        if (t2 <= ls.r) ls.eq();
        else if (t1 >= rs.l) rs.eq();
        else {ls.eq(); rs.eq();}
        maxx = max(ls.maxx , rs.maxx);
    }
    long long getmax()
    {
        if ((t1 <= l) && (r <= t2))
        {
            return maxx;
        }miniworld();
        if (t2 <= ls.r) return ls.getmax();
        else if (t1 >= rs.l) return rs.getmax();
        else {return max(ls.getmax() , rs.getmax());}
    }
};
template<>
struct dzpd<0>
{
    int l,r;
    long long maxx = 0ll,mini_add = 0ll,mini_eq = eggy;
    void bd(int bdl, int bdr) {l = bdl, r = bdr, maxx = a[bdl];}
    void add() {maxx += v;}
    void eq() {maxx = v;}
    long long getmax(){return maxx;}
};

struct dzpd <20> t;

int main()
{
    //freopen("P3373_2.in","r",stdin);
    n = read(), m = read();
    for (i = 1; i <= n; i++) a[i] = read();
    t.bd(1,n);
    for (i = 1; i <= m; i++)
    {
        t0 = read();
        switch(t0)
        {
            case 2:
                t1 = read(), t2 = read(), v = read();
                t.add(); break;
            case 3:
                t1 = read(), t2 = read();
                pf("%lld\n",t.getmax()); break;
            case 1:
                t1 = read(), t2 = read(), v = read();
                t.eq(); break;
        }
    }
    return 0;
}
long long read()
{
    long long x=0,f=1ll;
    char ch=_eggy();
    while(ch<48||ch>57)
    {
        if(ch=='-') f=-1ll;
        ch=_eggy();
    }
    while(ch>=48&&ch<=57)
    {x=x*10+ch-48,ch=_eggy();}
    return x*f;
}

by yyyx_ @ 2024-09-11 21:39:59

马蜂太抽象导致的


by cycyz @ 2024-09-11 21:47:41

我只能说您写的不叫代码,应该叫史。


by DongdongMan @ 2024-09-11 21:50:21

数组太多了!!!内存不够啊!!!


by ifffer_2137 @ 2024-09-11 21:51:22

本地能过编应该反思本地的问题(


by llamn @ 2024-09-12 20:59:12

不是这啥玩意,换成C++98就能AC???


|