• 我炸了


    本来T1和T2是有题解的,但是我重启了电脑,他们没了。。。
    T3

     这个嘛。。。有一大堆的做法。
    个人倾向于建图跑联通块

    awa
    可以发现,正着去算非常不好搞awa,所以就倒着来qwq
    code

    #include<bits/stdc++.h>
    #define ll long long
    using namespace std;
    int n;
    struct node
    {
        int x,h,fa;
    }e[1000001];
    const int MOD=998244353;
    ll f[1000001];
    inline ll read()
    {
        char c=getchar();ll a=0,b=1;
        for(;c<'0'||c>'9';c=getchar())if(c=='-')b=-1;
        for(;c>='0'&&c<='9';c=getchar())a=a*10+c-48;
        return a*b;
    }
    bool mycmp(node a,node b)
    {
        return a.x<b.x;
    }
    int main()
    {
        freopen("robot.in","r",stdin);
        freopen("robot.out","w",stdout);
        n=read();
        for(int i=1;i<=n;i++)
        {
            e[i].x=read();
            e[i].h=read();
        }
        stack<int> s;
        sort(e+1,e+n+1,mycmp);
        f[n]=2;    
        s.push(n);
        for(int i=n-1;i>=1;i--)
        {
            while(s.size()!=0&&e[i].x+e[i].h>e[s.top()].x)s.pop();
            f[i]=f[i+1];
            if(s.size()!=0)
            {
                f[i]+=f[s.top()]%MOD;
            }
            else
            {
                f[i]=(f[i]+1)%MOD;
            }
            s.push(i);
        }
        cout<<f[1]%MOD<<endl;
        return 0;
    }
  • 相关阅读:
    使用积分图像统计元素
    compareHist
    均值平移算法
    课后作业-阅读任务-阅读提问-1
    《对软件工程课程的期望》
    自我介绍
    作业
    结对-结对编项目作业名称-需求分析
    对软件工程课程的期望
    自我介绍
  • 原文地址:https://www.cnblogs.com/HLZZPawa/p/12884087.html
Copyright © 2020-2023  润新知