自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(76)
  • 收藏
  • 关注

原创 阿里笔试 反池化

#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

原创 牛客网 瞎位移群岛

#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

原创 牛客网 柠檬树

https://ac.nowcoder.com/acm/problem/212478线段树 维护区间最近公共祖先树状数组维护颜色信息前缀和lct动态加点维护集合信息然后对查询按右端点排序,离线查询,最后输出#include <bits/stdc++.h>using namespace std;const int N = 1e6+10;int h[N], e[N], nxt[N], idx;int t[N], dep[N], fa[N][20];int c[N],

2021-07-10 09:11:01 122

原创 CCF CSP 化学方程式

模拟题 + 简单的递归#include <bits/stdc++.h>using namespace std;//2H2+2Cl2=4HClint find_ep(string &s){ for(int i = 0; i < s.size(); ++ i) if(s[i] == '=') return i; return -1;}//2//H2void work_2(string word, map<string,int> &am

2021-03-02 22:13:43 260

原创 2020-09-3 CCF CSP 点亮数字人生(拓扑排序 判环)

经典急了急了。。第三题判断环的存在有一万种方式,拓扑排序,甚至撸上去一个tarjan都行,非自己图快意淫出一个不存在的递归算法然后把心态调崩了。。导致只拿了五十分。100分:#include <bits/stdc++.h>using namespace std;const int N = 1e5+10;vector<int> iput[N], oput[N];string op[N];int du[N],bdu[N];int h[N], tot, n, m;

2021-03-02 22:12:50 435

原创 CCF CSP 有趣的数

#include <iostream>#include <cstring>using namespace std;const int N = 1e3+10, mod = 1e9+7;int n;int C[N][N];void init(){ for(int i = 0; i < N; ++ i) for(int j = 0; j <= i; ++ j) if(!j) C[i][j] = 1; ...

2021-02-24 17:00:30 141

原创 CCF CSP 2020-06-04 1246

根据最大的测试数据 n可取到1e9 可知 应该采取logn或者 根号n的 复杂度的算法目测是一个动态规划 然后利用矩阵乘法来加速运算,根据输入的字符串推出他是由1246中的哪一个转移形成的 然后输出即可#include <bits/stdc++.h>#define LL long longusing namespace std;const int mod = 998244353;int n;string s;LL a[4][4] = { 0,1,0,0, 0,0,1,0

2021-01-21 17:08:50 2657 13

原创 PAT 表达式转换

链接:https://pintia.cn/problem-sets/15/problems/827跟csp认证模拟题有一拼的模拟题#include <iostream>#include <stack>#include <map>using namespace std;const int INF = 1e9;stack<int> stk;map<char ,int> mp;string s; int F;void prin

2020-10-21 10:59:38 212

原创 计算机图形学简笔画

DDALfunction img = DDA(x1, y1 ,x2 ,y2, img1)img = img1;dx = x2 - x1;dy = y2 - y1;d = max(abs(dx), abs(dy));kx = dx / d;ky = dy / d;x = x1;y = y1;for i = 1 : d img(round(x), round(y)) = 1; x = x + kx; y = y + kx;end;end;Bresenham

2020-10-21 09:22:36 920

原创 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

原创 CCF CSP 201403-4 网络延迟

树的最长直径#include <iostream>#include <cstring>using namespace std;const int N = 1e5+10;int d[N], ans;int h[N], tot, vis[N];struct Edge{ int to,nxt,w;}e[N << 1];void add(int a,int b,int c){ e[tot].to = b, e[tot].w = c, e[

2020-09-03 15:23:43 159

原创 CCF CSP 201909-5 城市规划

有依赖的树形背包问题第一维 循环物品第二维 循环体积第三维 循环决策#include <bits/stdc++.h>#define LL long longusing namespace std;const int N = 1e5+10, M = 5e5+10;const int INF = 1e15;int h[N], ep;struct Edge{ int to, nxt, w;}e[M];int n, m, K;int du[N], vis[N], .

2020-08-31 15:44:26 665

原创 CCF CSP201912-4 区块链

说明:大多数网上说这个题目是stl跟bfs 这里纠正一下除了一开始建一个图之外 其余跟图没有半点关系,stl也只用了一个队列,手写完全没有问题,如果你看到的博客说是stl或者bfs的话,大概率他没实现 或者没写对 或者超时。 正解是写一个结构体存时间 对其排序 插入块或者查找之前对队列中之前的时间的任务都取出执行原代码思想:用priority_queue对 执行时间进行排序 但是超时参考代码:改成普通队列就可以过 但是根据分析t 不是严格递增的 这样bfs中的判断是有问题的 但是竟然可以过。感觉测试

2020-08-30 21:13:49 324

原创 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

原创 CCF CSP 201909-3 字符画

调试字符串模拟的代码可 太虚了。。#include <bits/stdc++.h>using namespace std;const string ESC(1, char(27));int n, m, p, q;struct node{ int r, g, b; bool operator!=(const node &y)const { return r != y.r || g != y.g || b != y.b; }}RGB[2000][2000];i

2020-08-18 18:53:38 242

原创 CCF CSP 2020-06-03 Markdown渲染器

#include <bits/stdc++.h>using namespace std;int w;struct Node{ string s; int f; // 1段落 2项目开头 3项目第2-n段落 };vector<Node> all;bool f2(string &str){ return str.size() >= 2 && str[0] == '*' && str[1] == ' ';}.

2020-08-17 22:40:55 740

原创 CCF CSP 2019-12-05 魔数

BFS搜出所有转移状态 然后+线段树+懒标记+__int128乘法运算+ 动态规划优化build函数的节点初始化少了任何一个优化都过不去一个优化都不少也有可能过不去,时间卡的太极限了,可能还有极致的优化...#include <bits/stdc++.h> #define ull unsigned long longusing namespace std;const ull mod = 2009731336725594113;const int N = 1e6+10;u

2020-08-13 15:44:15 752 1

原创 CCF CSP 2020-06-05 乔乔和牛牛逛超市

买了x才能买y 等价于要想得到y的最大收益就必须连带着把x的最大收益(即使可能<0)也得收下,这个模型是典型的最大权闭合子图,答案应该是图中正的点权和-最小割的容量。最小割跑最大流模板就可得到。但是第二类点的建图方式还没想到,可能是需要拆点。#include <iostream>#include <cstring>#include <algorithm>#include <cmath>#define LL long longusing n

2020-08-10 16:08:07 2085 2

原创 CCF CSP 管道清洁 无源上下界最小费用可行流

#include <iostream>#include <cstring>#include <algorithm>using namespace std;const int N = 1e5+10, M = 1e6+10, INF = 0x3f3f3f3f;int h[N],ecnt,A[N];struct Edge{ int to,nxt,f, w;}e[M];int q[M],vis[N],dis[N], flow[N], pre[N];i.

2020-08-10 13:34:57 286 1

原创 CCF CSP 推荐系统

#include <iostream>#include <cstring>#include <algorithm>#include <set>#include <unordered_map>#define LL long long#define PII pair<LL,LL>using namespace std;const LL MUL = 1e9 + 10;unordered_map<LL,int> .

2020-08-05 13:18:24 452 3

原创 CCF CSP 消息传递接口

#include <bits/stdc++.h>using namespace std;const int N = 1e5+10;char str[N];int in[N];struct Node{ int s,f,t;};vector<Node> procs[N];Node q[N];int n;bool deal(){ int top = 0; q[++ top] = procs[0].back(); procs[0].pop_back(); in[.

2020-08-04 11:17:13 362

原创 nsXgInGPua

搬家

2020-03-21 12:40:36 100

原创 7-42 愿天下有情人都是失散多年的兄妹

个人认为这个题的测试数据有问题。前边已经对sexs设置过初值,后边else语句不加过不了最后一个测试点,说明存在对一个人性别的反复修改。因为性别不同输出是不一样的。ac代码:#include <bits/stdc++.h>using namespace std; const int N = 3e5+10; int h[N],tot,vis[N];bool ...

2020-03-12 00:37:57 312

原创 分层图的两种建法

1:实实在在的建图,n层2:逻辑上的对图分层,一般就是给dis数组或者vis数组,总之就是你需要参与求解实际问题的数据结构额外增加一维数组来模拟n层的效果例题:ACWing340通信线路第一种:优先队列 按照pair的第一个int按降序排列,所以路径设置为-w,但是无关紧要,它只提供选择顺序,真正修改的是dis数组,输出的也是dis数组的值。#include<bits/...

2019-12-25 16:13:26 1307

转载 POJ 1324 BFS+二进制状态标记

STL容器开在函数体内和体外还能卡超时?涨姿势了#include<iostream>#include<cstring>#include<queue>using namespace std;const int maxr = 30, maxc = 30;int maze[maxr][maxc],vis[maxr][maxc][1<<15...

2019-12-25 11:49:11 121

原创 POJ 2449 A*+最短路

是的 不压行就不会作死,当你调试半天调不对的时候一般是你很sb的随手打错一行你以为肯定不会错的代码,就当锻炼纠错能力了(本质还是菜。。)#include<iostream>#include<cstring>#include<queue>using namespace std;#define maxn 1005#define maxm 500005...

2019-12-19 21:57:48 88

原创 POJ 1724 分层图最短路

分层图的两种建法1:直接建k-1层图2:给dis或vis或你需要记录信息的数组额外增加一维模拟n层图的效果至于分层图的理解,个人认为就是有一些干扰信息时,比如免费经过一些路径或者有特殊限制的时候,可以从当前图免费跳到下一层或上一层图来转换状态。#include <cstdio>#include<algorithm>#include<cstring...

2019-12-18 21:32:12 162

原创 poj 生日蛋糕 剪枝+dfs

头一次见这么夸张的剪枝操作。这个点也很难想2*r*h=S *r*r*h=V * =>V*2/r = SS + sumS >= best => return;#include <cstdio>#include<algorithm>#include<cmath>using namespace std;int bes...

2019-12-18 11:16:31 128

原创 POJ 1376 bfs

建图的方式有点特别,建在 方格的四个顶点处vis三维数组,第三维记录走过节点的方向#include<cstdio>#include<cstring>#include<queue>#include<algorithm>#include<map>const int maxn = 1e2+10;using namespac...

2019-12-17 20:43:21 83

原创 POJ1475 双bfs 找最短路

第一层bfs找箱子移动的最短路,第二层找人到箱子后边位置的最短路。难点可能是第一层bfs的vis数组需要开三维,需要同时记录走过点的方向。其实字符串的处理,路径输出也很恶心。。。属于稍微有点错就得调半天那种#include<iostream>#include<algorithm>#include<cstdio>#include<cstr...

2019-12-16 20:43:22 198

转载 POJ 3190 Stall Reservations 贪心算法

优先队列 模拟处理一下#include<cstring>#include<cstdio>#include<algorithm>#include<queue>using namespace std;const int maxn = 1e5+10;struct Node{ int l,r,pos; bool operator &lt...

2019-12-12 17:09:56 101

转载 POJ 1390 Blocks 区间DP

区间DP的核心:把大区间分解成相同规模的小区间,小区间返回子结构的值给大区间从而得到最优解。但是怎么就能根据不同的题模拟出特定的比较合适的子结构呢?我觉得与其说这是一种编码的熟练度问题,不如说是对实际问题建模的敏感度问题。如何设计优秀的子结构问题真的很考验一个人的最基本最核心的创造力和分析能力,刷题套模板真的能整出来吗。。。就拿这个题来说,可以很轻易的想到dp[i][j]为i到j区间的最优值,...

2019-12-12 16:32:29 134

转载 POJ 2373 Dividing the Path 单调队列dp

两个队列 p和qp存储当前所有已经访问过的节点q对p中的节点进行筛选 选出可以对当前节点进行状态转移的节点,头节点就是最小值,维护这两个队列,时间复杂度就可以降下来但是不清楚为什么模拟队列的时候永远是h = 1,t = 0#include<iostream>#include<cstring>using namespace std;const int ...

2019-12-12 12:53:59 113

转载 POJ 炮兵阵地 (状态压缩dp)

真的很难,状态转移方程太难推了,智商不够,努力来凑#include<iostream>#include<algorithm>#include<cmath>#include<cstring>using namespace std;const int maxn = 1e2+10;int dp[maxn][maxn][maxn],cur[...

2019-12-10 21:18:58 138

原创 POJ 2186 Popular Cows (tarjan缩点 染色 出度标记)

虽然不是很难,但是每次都能写着写着有点迷,还是记录一下吧#include<iostream>#include<algorithm>#include<cmath>#include<cstring>using namespace std;const int maxn = 1e5+10,maxm = 5e5+10;int n,m,timi...

2019-12-08 21:50:30 83

原创 POJ3468 线段树A Simple Problem with Integers

我还是第一次见一会对 一会不对的评测系统。。。一样的代码 一次对一次不对??#include<iostream>#include<algorithm>#include<cstring>#define lc rt<<1#define rc rt<<1|1using namespace std;const int maxn ...

2019-12-06 21:52:04 68

原创 POJ3264 区间最大减区间最小

区间操作,线段树和打表都行,主要打表的操作老是加一和减一搞晕,重写一遍找找感觉#include<iostream>#include<algorithm>#include<cstring>using namespace std;const int maxn = 5e4+10;int n,m,a[maxn];int dp1[maxn][80],dp...

2019-12-06 20:18:59 91

原创 POJ3321 苹果树

体会一下 树状数组是怎么用的,还是太菜了#include<iostream>#include<cstring>using namespace std;const int maxn = 3e5+10;int L[maxn],R[maxn],timing;int c[maxn],a[maxn];int tot,head[maxn];struct Edge{...

2019-12-06 19:58:26 114

原创 蓝桥杯 小计算器

细节还是蛮多的,如果为0的话要显示输出0,不然只有三十分。模拟题还是菜了点,基础不够扎实。。。#include<bits/stdc++.h>using namespace std;long long sum;int base = 10;long long read(){ string s; cin >> s; long long x = 0; fo...

2019-12-06 17:27:56 591 1

原创 poj2446 chessboard

明明说了m,n不超过32,死活过不去,最后设置成2000才过,测试范围难道就是随便说说的?#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<string>#include<map> const int ...

2019-12-06 11:00:08 103

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除