跳到正文

个人记录

做(错)题记录

One_Nonene约 4 分钟
原文
文章信息与版本

文章信息

发布
2026年2月7日
收录
2026年6月21日
更新
2026年11月14日
篇幅
约 4 分钟

版本

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

  2. diji不要pop两遍

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

  4. tuple是个好东西

C++
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. 用类似 LinkedLinked ForwardForward StarStar 的 方法,去存储P4107的树/图。好用好写不好理解

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

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

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

  1. 当你发现要求字典序最小的欧拉路径但链式前向星没法排序BELIKE:
C++
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);
}
  1. CF547D:连虚边去跑欧拉路径时连点0会超时,可以奇点两两相连
  2. Uva10129:判欧拉路时,对于一个可能有欧拉路的图,只需找一个点进行DFS判联通,如第一个使用的点
  3. P2657:对于这个题呀好像ld、lm的枚举是一种对数位dp可读性的优化
C++
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的游戏:对于带修的取糖果的问题可以把每一轮搞成一个函数,并进行Clamp同构,利用线段树维护

原文