首页 > 其他分享 >cm

cm

时间:2024-10-18 21:11:31浏览次数:1  
标签:rt return cm int mid pos define

CTH 使我假完了!都怪 CTH !!!

后天再调

#include<bits/stdc++.h>
#define int long long
#define me(a) memset(a, 0, sizeof a)
#define lson ls[rt]
#define rson rs[rt]
#define Aqrfre(x, y) freopen(#x ".in", "r", stdin),freopen(#y ".out", "w", stdout)
#define mp make_pair
#define Type int
#define qr(x) x=read()
typedef __int128 INT;
typedef long long ll;
using namespace std;

inline Type read(){
    char c=getchar(); Type x=0, f=1;
    while(!isdigit(c)) (c=='-'?f=-1:f=1), c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48), c=getchar();
    return x*f;
}

const int N = 505; 
const int mod = 998244353;

int n, m, res, tot, dis[N][N];
vector<int>to[N], belong[N<<1];

int top, th, s[N], bcc, low[N], dfn[N];
vector<int>BCC[N]; int sz[N];
inline void tarjan(int x, int p){
    s[++top] = x;
    low[x] = dfn[x] = ++th;
    for(int y : to[x]){
        if(!dfn[y]){
            tarjan(y, x);
            low[x] = min(low[x], low[y]);
            if(low[y] == dfn[x]){
                ++bcc;
                do{ BCC[bcc].emplace_back(s[top]); sz[bcc]++;
                    belong[s[top]].emplace_back(bcc);
                }while(s[top--] != y);

                BCC[bcc].emplace_back(x); sz[bcc]++;
                belong[x].emplace_back(bcc);
            }
        }
        else low[x] = min(low[x], dfn[y]);
    }
}

vector<int>tw[N<<2][N];
int v[N<<5], rtot, ls[N<<5], rs[N<<5], root[(N*N)<<1];
inline void pushup(int rt){
    v[rt] = (ll)(v[lson] + v[rson]) % mod;
} 

inline void update(int &rt, int l, int r, int pos, int val){
    if(!rt) rt = ++rtot;
    if(l == r){
        (v[rt] += val) %= mod;
        return;
    }

    int mid = (l + r) >> 1;
    if(pos <= mid) update(lson, l, mid, pos, val);
    else update(rson, mid+1, r, pos, val);

    pushup(rt);
}

inline int merge(int x, int y, int l, int r){
    if(!x or !y) return x + y;
    if(l == r){
        (v[x] += v[y]) %= mod;
        return x;
    }
    int mid = (l + r) >> 1;
    ls[x] = merge(ls[x], ls[y], l, mid);
    rs[x] = merge(rs[x], rs[y], mid+1, r);

    pushup(x); return x;
}

inline void mcpy(int &x, int y, int l, int r){
    if(!y) return;
    if(!x) x = ++rtot;
    v[x] = v[y];
    if(l == r) return;
    int mid = (l + r) >> 1;
    mcpy(ls[x], ls[y], l, mid);
    mcpy(rs[x], rs[y], mid+1, r);
}

inline int query(int rt, int l, int r, int pos){
    if(!rt) return 0;
    if(l >= pos){
        return v[rt] % mod;
    }
    int mid = (l + r) >> 1, res = 0;
    if(mid >= pos) res = query(lson, l, mid, pos);
    (res += query(rson, mid+1, r, pos)) %= mod;
    
    return res;
}

inline int qpos(int rt, int l, int r, int pos){
    if(l == r) return v[rt] % mod;
    int mid = (l + r) >> 1;
    if(mid >= pos) return qpos(lson, l, mid, pos);
    else return qpos(rson, mid+1, r, pos);
}

int ned;
inline void dp(int x, int p, int goal, int whi){
    int num = 0, G = 0;
    for(int y : tw[whi][x]){
        if(y == p) continue;
        cout<<ned<<":|| ";
        if(G and !p){
            ++ned;
            mcpy(root[ned], root[x], 1, n);
            cout<<query(root[x], 1, n, 1)<<" "<<y<<" Cone Im\n";
        }
        if(y == goal){
            // root[st] = merge(root[st], root[ned], 1, n);
            int valo = query(root[ned], 1, n, goal);
            update(root[goal], 1, n, goal, valo);
            // if(ned == 8) cout<<query(root[x], 1, n, 1)<<" You Wanty\n"; 
            
            cout<<ned<<" "<<x<<" "<<valo<<" Get Goal\n";
            G = 1;
            continue;
        }
        if(!p){
            cout<<"Change ";
            G = 1;
        }

        // cout<<y<<": ";

        num = query(root[ned], 1, n, y);

        update(root[ned], 1, n, y, num);

        // cout<<num<<" "<<query(root[ned], 1, n, 1)<<"\n";

        dp(y, x, goal, whi);
    }
    
}

inline void dfs(int x, int p, int bel){
    cout<<x<<" "<<p<<" "<<bel<<endl;
    update(root[x], 1, n, x, 1);
    for(int whi : belong[x]){
        if(whi == bel) continue;

        if(sz[whi] == 2){
            int num = 0;
            // cout<<" "<<x<<" Kill You\n";
            for(int y : tw[whi][x]){
                if(y == p) continue;
                // cout<<y<<" To\n";
                dfs(y, x, whi);
                root[x] = merge(root[x], root[y], 1, n);
                num += query(root[y], 1, n, x);
            }
            update(root[x], 1, n, x, num);

            // cout<<qpos(root[x], 1, n, x)<<" PoOp\n";
            continue;
        }

        for(int i : BCC[whi]){
            if(x == i) continue;
            int num = 1; 
            // cout<<i<<"  has these things:"<<endl;
            for(int y : to[i]){
                if(y == x or y == p) continue;
                bool ch = 1;
                for(int p : belong[y])
                    if(p == whi){ ch = 0; break; }
                if(!ch) continue;
                // cout<<"See Me: "<<i<<" "<<y<<endl;
                dfs(y, i, whi);
                (num += query(root[y], 1, n, i)) %= mod;
                root[i] = merge(root[i], root[y], 1, n);
            }
            update(root[i], 1, n, i, num);
            // if(i == 5) cout<<query(root[i], 1, n, 1)<<" Query\n";
            // cout<<qpos(root[i], 1, n, i)<<" The Pos's Ans is \n";
        }

        for(int i : BCC[whi]){
            if(x == i) continue;
            ++ned;
            cout<<i<<" ";
            cout<<ned<<" with: "<<query(root[i], 1, n, 1)<<" Now's start\n";
            mcpy(root[ned], root[i], 1, n);
            // cout<<root[ned]<<":\n";
            dp(i, 0, x, whi);
            // merge(root[x], root[ned-1], 1, n);
            // merge(root[x], root[ned], 1, n);
        }
    }
}

inline void clean(){
    fill(root, root+1+ned, 0);
    fill(ls, ls+1+rtot, 0);
    fill(rs, rs+1+rtot, 0);
    fill(v, v+1+rtot, 0);
    rtot = 0; ned = n;
}

signed main(){ //algebra
    Aqrfre(a, a);

    qr(n), qr(m); ned = n;
    for(int i=1; i<=m; i++){
        int qr(x), qr(y);
        dis[x][y] = dis[y][x] = 1;
        to[x].emplace_back(y);
        to[y].emplace_back(x);
    }

    for(int i=1; i<=n; i++)
        if(!dfn[i]) tarjan(i, 0);

    for(int i=1; i<=bcc; i++)
        for(int x : BCC[i])
            for(int y : BCC[i]){
                if(x == y) continue;
                tw[i][x].emplace_back(y);
            }


    int la = 0;
    for(int i=1; i<=n; i++){
        clean(); dfs(i, 0, 0);
        (res += qpos(root[i], 1, n, i)) %= mod;
        cout<<res-la<<" AnsNow\n";
        la = res;
        cout<<"\n-----------------"<<endl;
    }

    cout<<res<<"\n";


    return 0;
}

标签:rt,return,cm,int,mid,pos,define
From: https://www.cnblogs.com/YuenYouth/p/18475056

相关文章

  • 【芯智雲城】Broadcom博通BCM5389IFBG以太网控制器应用
    Broadcom公司的BCM5389IFBG以太网控制器芯片,适用于独立的千兆以太网交换机和千兆以太网控制平面及背板应用。一、芯片特点集成度高:BCM5389IFBG将数据包缓冲区、SerDes(串行解串器)、媒体访问控制器(MAC)、地址管理和非阻塞交换结构集成到一个0.13µmCMOS器件中,减少了系统的复杂......
  • GCM
    GaloisCounterMode(GCM)运算符与函数$0^s$包含了$s$个$0$的比特串。$\mbox{CIPH}_K⁡(X)$在密钥$K$下对分组$X$应用分组密码得到的输出。$\mbox{GCTR}_K⁡(ICB,X)$在密钥K下对包含初始组计数$ICB$的比特串X应用包含给定分组加密的$\mbox{GCTR}$函数的输出。$\m......
  • CMDB平台(基础篇):CMDB的概念以及现状
    CMDB:IT界的“超级大脑”,现状却让人哭笑不得在IT界,有一个神秘而强大的存在,它被称为CMDB——资产配置管理。听起来就像是《复仇者联盟》里的超级英雄,但实际上,它更像是IT界的“超级大脑”,默默记录着每一个IT组件的“身世”和“关系网”。 那CMDB到底是什么呢?下面我们就聊一聊CM......
  • 右键以管理员身份打开CMD(Windows)
    注册表编辑器win+r输入regedit打开注册表编辑器找到计算机\HKEY_CLASSES_ROOT\Directory\Background\shell新建runas项选中runas然后右键新建字符串,命名为icon双击icon,输入cmd.exe选中runas然后右键新建DWORD(32位)值(D),命名为ShowBasedOnVelocityId双击ShowBasedOnVelocit......
  • 【ACM独立出版 | EI稳检索 】第三届公共卫生与数据科学国际学术会议(ICPHDS 2024)
    随着大数据和人工智能的迅速发展,数据科学在公共卫生领域的应用越来越广泛。会议议题将涵盖公共卫生数据的收集、处理、分析和解读,以及数据科学在流行病学、健康管理、决策支持、公共卫生政策、数据科学理论、人工智能技术、健康大数据分析等方面的应用。第三届公共卫生与数据科......
  • CMSC Manual testing Completeness SNU Score
    Homework#3Due:Friday,October18that4:00pmCSTTableofContentsHomework#3GettingstartedManualtestingCompletenessSNUScoreCodeQualitySubmissionThepurposeofthisassignmentistogiveyouexperiencewithconditionals,lists,andloops.......
  • CMDB不值得...
    在运维管理中,CMDB是一直是一个争议较大的产品,或者说作为一种管理理念,认同这一理念的人将之奉为圭臬,不惜花几十上百万、甚至数百万来打造CMDB,不认同的人觉得它甚至还不如Excel表格实用。01.被误解的CMDB实际上,CMDB可能并没有想像中的那么好,但也没有那么糟糕。作为一个泊来品,CMDB......
  • ACME续签证书在Linux云服务器上安装指南
    环境供应商;阿里云服务器操作系统:LinuxCentosStream9操作系统静态代理:Nginx前言我这边使用https://get.acme.sh方式无法正常使用,会卡在这个页面,无任何进度的信息。最终我使用了gitclone的方式进行安装。正文clone项目下来,并进行install初始安装ACME环境gitcloneht......
  • SciTech-AV-Audio-Coding-PCM(Pulse Code Modulation)-脉码编码调制: 无压缩-无损编码
    SciTech-AV-Audio-DAP(DigitalAudioProcessing)-LoudnessNormalization(响度规范化):PerceivedLoudness+RMS(RootMeanSquare)PCM(PulseCodeModulation)也被称为脉码编码调制,PCM的声音数据没有被压缩,它是由模拟信号经过Sampling、Quantilization、Code转换成的标......
  • YCM中previewwindow显示函数类型信息如何实现
    intro在使用YCM的自动提示功能时,可以注意到选择complete提供的条目时,窗口的上面还有一个小窗口提示这个函数的声明信息,包括了函数的参数列表和类型信息。这个对写代码非常有用,对于一段时间不看的函数,很容易记不得函数的参数列表和各自的类型信息,以至于在官方issue中希望提供一个......