- 博客(13)
- 资源 (2)
- 收藏
- 关注
原创 pta520钻石争霸赛题解
水题直接贴代码 #include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; printf("%d! 520!",n); return 0; } 简单if分支语句 #include <bits/stdc++.h> using namespace std; int main() { int n,m,k; scan.
2022-05-23 19:13:35
473
1
原创 矩阵距离(bfs)
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define INF 100000 inline ll read(){ ll x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } whi.
2022-04-04 10:40:56
335
原创 树形DP+容斥原理(处理树上染色问题)
这题的题意大概就是给定一个具有 N 个顶点和 N-1 条边的连通无向图,只用 3 种颜色为所有顶点着色。 现在,一些顶点已被着色。您应该为剩余的顶点着色,并保证每对直接连接的顶点不应该是相同的颜色。请计算所有剩余顶点着色的方案数取模10^9+7。 一眼树形DP题:三种情况 1.//有父亲节点的点的方案数 2.已经染色的节点的方案数 3/独立节点的方案数 分开处理就好 #include<bits/stdc++.h> using namespace std; typedef long long l.
2022-04-01 20:33:33
885
原创 石子合并加强版
区间DP模板题 #include<bits/stdc++.h> using namespace std; typedef long long ll; inline ll read(){ ll x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>=.
2022-03-30 21:00:04
546
原创 最长公共子序列(LCS)
最长公共子序列一般解法 时间 o(nn)空间 nn #include<bits/stdc++.h> using namespace std; typedef long long ll; inline ll read(){ ll x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); }
2022-03-30 18:33:38
450
原创 2021-10-27
台州学院1024程序员新生C语言大赛 签到题 只需明白每个人中间需要空一个位置 直接(x+1)/2 即可 签到题注意格式即可 题意大致为寻找一个数的俩边都比这更数小的组合有多少个 由于这里数据只有10000 所以我们直接暴力向俩边搜索即可 以下是c++版 c语言替换输入输出即可 include <iostream> #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e4
2021-10-27 20:41:48
188
原创 2021ccpc中国大学生程序设计竞赛网络选拔赛1009
标记走过点的次数,该点的连续子序列为次数减一 累加即可得到正解 #include<bits/stdc++.h> #include<string> using namespace std; typedef long long ll; using namespace std; #define inf 0x3f3f3f3f const int N=1e5+10; map<pair<int,int>,int>a; int main(){ int n; int..
2021-08-28 19:41:22
264
原创 处理线段相交问题
快速排斥 就是初步的判断一下,两条线段是不是相交,以两条线段为对角线的矩形,如果不重合的话,那么两条线段一定不可能相交。 <1>线段ab的低点低于cd的最高点(可能重合) <2>cd的最左端小于ab的最右端(可能重合) <3>cd的最低点低于ab的最高点(加上条件1,两线段在竖直方向上重合) <4>ab的最左端小于cd的最右端(加上条件2,两直线在水平方向上重合) 综上4个条件,两条线段组成的矩形是重合的。 (2) 跨立实验 如果两条线段相交,那么必须跨..
2021-08-19 14:41:38
223
原创 运用优先队列解决合并果子的贪心问题
根据题意确实比较好理解就是要使最多果子数量的那堆果子的合并次数比较少 #include<bits/stdc++.h> #include<string> using namespace std; typedef long long ll; using namespace std; const int N=10005; int sum[N]; priority_queue <int,vector<int>,greater<int> > q; int .
2021-08-15 19:07:34
152
原创 Arranging The Sheep
You are playing the game “Arranging The Sheep”. The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters ‘.’ (empty space) and ‘*’ (sheep). In one move, you can move any sh
2021-06-05 22:40:23
142
原创 2021-06-05
Grids On an 1 × 1 grid,partition the length and width into 50 parts,forming 2500 unit grids with the same size.Now,given n circles with equal radius R on the grid.Find the total number of unit grids which are not covered by any of a circl...
2021-06-05 22:33:50
84
原创 TZOJ 数据结构实验:一元多项式相加
给定两个多项式: A(x)=a0+a1x+a2x2+…+anxn B(x)=b0+b1x+b2x2+…+bmxm 计算C(x) = A(x) + B(x)。 多项式以链表形式存储(含头结点),其结点(Node类型)包含三个域,分别为系数、指数和指针域: coef exp next 题目部分代码已经完成,您只需要补充并提交以下函数: Node* Add(Node* A, Node* B);//其中A和B为A(x)和B(x)的链表头指针,返回值为C(x)的链表头指针 输入 第一行为多项式A(x),格式为a0+a
2020-03-08 10:50:42
3063
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人