DFS
hbulzh
这个作者很懒,什么都没留下…
展开
-
阿里笔试 反池化
#include <iostream> #include <cstring> #include <algorithm> using namespace std; int A, B, C, D; int _find(int x){ for(int i = 30; i >= 0; i --) if(x >> i & 1) return i; return 0; } int lg(int x){ int k.原创 2021-09-10 20:22:50 · 135 阅读 · 0 评论 -
牛客网 瞎位移群岛
#include<iostream> #include <cstring> #include <algorithm> #include <queue> using namespace std; const int N = 2e3 + 10; int flag[N]; int id[N][N]; pair<int, int> inputs[N]; int n, m, k, s, t; int d[4][2] = {0, 1, 0, -1, -1,.原创 2021-09-10 00:09:03 · 132 阅读 · 0 评论 -
CCF CSP 化学方程式
模拟题 + 简单的递归 #include <bits/stdc++.h> using namespace std; //2H2+2Cl2=4HCl int find_ep(string &s) { for(int i = 0; i < s.size(); ++ i) if(s[i] == '=') return i; return -1; } //2 //H2 void work_2(string word, map<string,int> &am原创 2021-03-02 22:13:43 · 260 阅读 · 0 评论 -
PAT 家庭财产
做不动LCT,就来敲个模拟题解解气吧 dfs 存个结构体维护信息 排个序 然后没了 #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 1e4+10, M = 1e6+10; int n, cnt; int h[N], tot; struct {int to,nxt;}e[M]; int houses[N], area[N],v原创 2020-10-19 15:41:40 · 93 阅读 · 0 评论 -
CCF CSP 201809-4 再卖菜
bfs + 记忆化搜索(剪枝) #include <bits/stdc++.h> using namespace std; const int N = 310; int a[N],b[N],f[N][N][N],n; bool dfs(int u) { if(u == n + 1) { if((a[n - 1] + a[n]) / 2 == b[n]) return true; return false; } for(int i = 0; i < 3; ++i) {原创 2020-08-18 23:42:49 · 180 阅读 · 0 评论 -
poj 生日蛋糕 剪枝+dfs
头一次见这么夸张的剪枝操作。 这个点也很难想 2*r*h=S * r*r*h=V * => V*2/r = S S + sumS >= best => return; #include <cstdio> #include<algorithm> #include<cmath> using namespace std; int bes...原创 2019-12-18 11:16:31 · 128 阅读 · 0 评论