做(错)题记录

· · 个人记录

  1. 有多个操作时考虑其中关系(Lesson2 小球染色)

  2. diji不要pop两遍

  3. 把字串等尽量与boder联系起来

  4. tuple是个好东西

tuple<ll,ll,ll...> tp;
auto [a,b,c] = tp;
stack<ll> st;
st.emplace(a,b,c);
ll a=get<0>(tp);
  1. 题目中梳理得到关系式,如果是有值域

  2. 把log2(x)换成__lg(x)。

  3. 用类似 Linked Forward Star 的 方法,去存储P4107的树/图。好用好写不好理解

  4. IDA*中可以用Astar判断是否超过lim,从而剪枝

  5. 四方向搜索,每次都要判断是否已经成功,否则会炸

10. memset全变成-1要用memset(name,255,sizeof(name))。

  1. 当你发现要求字典序最小的欧拉路径但链式前向星没法排序BELIKE:

    void ola_path(int x) {
    while(!G[x].empty()) {
       int v=G[x][G[x].size()-1];
       G[x].pop_back();//delete this edge -> no extra visiting.
       ola_path(v);
    }
    as.push(x);
    }
    int main(){
     for(int i=1;i<=n;i++)
         sort(G[i].begin(),G[i].end(),greater<int>());//biggest -> smallest
    ola_path(st);
    }
  2. CF547D:连虚边去跑欧拉路径时连点0会超时,可以奇点两两相连

  3. Uva10129:判欧拉路时,对于一个可能有欧拉路的图,只需找一个点进行DFS判联通,如第一个使用的点

  4. P2657:对于这个题呀好像ld、lm的枚举是一种对数位dp可读性的优化

    
    ll wk(ll x) {
    if(x <= 0) return 0;
    spt(x);
    to0(dp);
    dp[11][1][1][0] = 1;
    
    for(int i=10; i>=1; --i) {
        for(int ld=0;ld<=1;++ld) {
            for(int lm=0;lm<=1;++lm) {
                for(int k=0;k<=9;++k) {
                    int up=lm?a[i]:9;
                    for(int j=0;j<=up;++j) {
                        int ld_nw = ld && (j == 0);
                        int lm_nw = lm && (j == up);
                        if(!ld&&abs(j-k)<2) continue;
                        dp[i][ld_nw][lm_nw][j]+=dp[i+1][ld][lm][k];
                    }
                }
            }
        }
    }
    
    ll as = 0; 
    for(int ld=0;ld<=1;++ld) {
        for(int lm=0;lm<=1;++lm) {
            for(int j=0;j<=9;++j) {
                if(ld==1) continue; 
                as+=dp[1][ld][lm][j];
            }
        }
    }
    return as;
    }


[Ziyin和Zayin的游戏](https://marsoj.cn/newc/p/MNS274?tid=6ac7832f3b3f0704d1f7bbe2&problemsIndex=2):对于带修的取糖果的问题可以把每一轮搞成一个函数,并进行Clamp同构,利用线段树维护