- 博客(30)
- 收藏
- 关注
原创 CF1551B Wonderful Coloring
文章目录CF1551B1 Wonderful Coloring - 1CF1551B2 Wonderful Coloring - 2CF1551B1 Wonderful Coloring - 1题目描述AC代码:#include<bits/stdc++.h>using namespace std;long long num,ans,n;int a[30];string p;int main(){ int t; cin>>t; while(t--){ mem
2021-11-18 10:26:09
163
原创 CF1545A
题目描述TLE代码:(O(N^2))#include<bits/stdc++.h>using namespace std;int n,b[100005],pl;bool v[100005];struct node{ int num; int x;}a[100005];bool cmp(node a,node b){ return a.x<=b.x;}int main(){ int t; cin>>t; while(t--){ pl=1;
2021-11-16 18:45:37
692
原创 CF749C
题目描述AC代码:#include<bits/stdc++.h>using namespace std;int x,ta=0,tb=0;char p;bool n[2000005];queue<int> aa;queue<int> bb;queue<int> t;int main(){ memset(n,0,sizeof(n)); cin>>x; p=getchar(); for(int i=1;i<=x;i++)
2021-11-15 19:50:41
525
原创 CF448C
题目描述AC代码:#include<bits/stdc++.h>using namespace std;int n,a[5010];int dfs(int l,int r){ if(l>r) return 0; if(l==r) return min(a[l],1); int maxn=0,x=2e9; for(int i=l;i<=r;i++){ if(x>a[i]){ x=a[i]; maxn=i; } } for(int i=l
2021-11-15 18:39:11
143
原创 CF1400E
题目描述AC代码:#include<bits/stdc++.h>using namespace std;int n,a[5010];int dfs(int l,int r){ if(l>r) return 0; if(l==r) return min(a[l],1); int maxn=0,x=2e9; for(int i=l;i<=r;i++){ if(x>a[i]){ x=a[i]; maxn=i; } } for(int i=l
2021-11-15 18:34:24
102
原创 快读模板2.0
#include<bits/stdc++.h>using namespace std;int inline read(){ int x=0,f=1; char c=getchar(); while(c<'0'||c>'9'){ if(c=='-')f=-1; c=getchar(); } while(c>='0'&&c<='9'){ x=x*10+c-'0'; c=getchar(); } return x*f;}in
2021-10-20 20:00:18
81
原创 合并石子(算法进阶)(待完成)
#include<bits/stdc++.h>using namespace std;int f[4005][4005];int sum[40005],a[40005];int n;inline int read(){ int x=0,f=1; char ch=getchar(); if(!isdigit(ch)){ if(ch==45)f=-1;ch=getchar(); } while(isdigit(ch)){ x=x*10+ch-48;ch=getchar()
2021-10-16 21:22:22
118
1
原创 快读模板
inline int read(){int x=0,f=1;char ch=getchar();if(!isdigit(ch)){if(ch==45)f=-1;ch=getchar();}while(isdigit(ch)){x=x10+ch-48;ch=getchar();}return xf;}
2021-10-16 20:35:06
123
1
原创 高精度模板2.0
代码:#include<bits/stdc++.h>using namespace std;const int SIZE=10010;struct Int{ int len,n[SIZE]; void Set(int l){ len=l; for(int i=1;i<=len;i++) n[i]=0; } Int(char *s){ len=strlen(s); for(int i=len-1;~i;i--){ if(s[i]<='9'&
2021-10-16 19:20:01
113
1
原创 命名空间小技巧
#include<bits/stdc++.h>namespace baoli{ void work(){ return; }}namespace std{ void work(){ return; }}int main(){ baoli::work(); std::work(); return 0;}作用:节省空间小数据不爆零。
2021-10-09 22:09:51
668
1
原创 输入黑科技
#include<bits/stdc++.h>using namespace std;int main(){ int a[10010]; int n=0,x; while(~scanf("%1d",&x)){ a[++n]=x; } for(int i=1;i<=n;i++) printf("%d ",a[i]); return 0;}
2021-10-09 22:03:03
75
1
原创 合并石子(洛谷)
合并石子#include<iostream> #include<cstdio> #include<cmath> using namespace std; int n,minl,maxl,f1[300][300],f2[300][300],num[300]; int s[300]; inline int d(int i,int j){return s[j]-s[i-1];} //转移方程:f[i][j] = max(f[i][k]+f[k+1
2021-10-09 21:58:55
127
1
原创 高精度(模板)
代码 :#include<bits/stdc++.h>using namespace std;const int MAX_SIZE = 1010;struct Int { int len, n[MAX_SIZE]; void Set(int l) { len = l; for(int i = 1; i <= len; i ++) n[i] = 0; } Int(char *s) { len = strlen(s); for(int i = len - 1;
2021-10-08 23:04:42
78
1
原创 SP15637 GNYR04H - Mr Youngs Picture Permutations(洛谷)
https://www.luogu.com.cn/problem/SP15637算法:(线性DP);代码:#include<bits/stdc++.h>using namespace std;int t,n[10];int main(){ while(cin>>t){ if(t==0){ return 0; } memset(n,0,sizeof(n)); for(int i=
2021-10-06 21:52:01
228
1
原创 关押罪犯(洛谷)
P1525【NOIP2010 提高组】 关押罪犯算法:图论,贪心,并查集,排序,二分图代码:#include <cstdio>#include <algorithm>using namespace std;struct data{ int x; int y; int z;}f[100005];int n,m,fa[20005],b[20005],i;bool cmp(data a,data b){ return a.z>b.z;}int
2021-10-06 10:24:41
159
4
原创 最近公共祖先(LCA)(洛谷)
P3379代码:#include<bits/stdc++.h>using namespace std;const int SIZE=500005;int head[SIZE],nxt[SIZE*2],ver[SIZE*2],tot=0;int n,m,s,t,d[SIZE],f[SIZE][20];queue<int> q;void add(int x,int y){ ver[++tot]=y,nxt[tot]=head[x],head[x]=tot;}voi
2021-10-05 21:40:08
110
2
原创 最小生成树(洛谷)
P3366代码(Kruskal算法):#include<bits/stdc++.h>using namespace std;struct rec{ int x; int y; int z;}edge[200005];int n,m,ans,tot=0;int fa[5005];bool cmp(rec a,rec b){ return a.z<b.z;}int get(int x){ if(fa[x]==x) return x; else return f
2021-10-05 21:08:24
150
2
原创 单元最短路径(洛谷)
P3371P4779代码(Dijkstra算法):#include<bits/stdc++.h>using namespace std;const int N=10005;const int M=500005;int head[M],edge[M],ver[M],nxt[M],tot=0;bool v[N];int d[N];long long n,m,s;priority_queue< pair<int,int> > q;void add(in
2021-10-05 20:48:26
109
3
原创 2021-10-05模拟赛总结
文章目录总括一、寻找道路二、国王游戏三、书柜的尺寸四、海底珍珠串总括题数:4时间:4h得分:一、寻找道路P2296 寻找道路来源:洛谷(NOIP2014 提高组)算法:图论,搜索,模拟水题得分:100代码:#include<bits/stdc++.h>using namespace std;int n,m,ss,ee;bool p1[10005],p2[10005];int head1[200005],nxt1[200005],ver1[200005],
2021-10-05 14:23:06
648
5
原创 字典树(洛谷)
P2580 于是他错误的点名开始了map代码:#include<bits/stdc++.h>using namespace std;typedef long long ll;map<string,int>a; string s;int n,m;int main(){ cin>>n; while(n--){ cin>>s; a[s]=1; } cin>>m; while(m-
2021-10-05 06:54:52
224
6
原创 发射站(洛谷)
P1901发射站算法:单调栈代码:#include<bits/stdc++.h>using namespace std;const int N=1000010;int h[N],v[N],ans[N],mx;stack<int> s;int main(){ int n; cin>>n; for(int i=1;i<=n;i++) cin>>h[i]>>v[i]; for(int i=1;i<
2021-10-04 19:47:36
343
1
原创 单调栈(洛谷)
P5788(洛谷)P5788 单调栈思路:维护一个单调递减的栈,重复执行:当入栈的下标所对应的值,那么入栈的下标为栈顶下标的f(x)的值,存入ans函数,并弹出栈顶元素。代码:#include<bits/stdc++.h>using namespace std;stack<int> w;int a[3000005],ans[3000005];int n;int main(){ scanf("%d",&n); for(int i=1;i<=n;i
2021-10-04 19:23:09
439
5
原创 树状数组模板(洛谷)
P3374#include<bits/stdc++.h>using namespace std;#define maxn 500010int a[maxn],f[maxn],n,m;int lowbit(int x){ return x&-x;}void addion(int x,int y){ while(x<=n){ f[x]+=y; x+=lowbit(x); }}int getsum(int x){ int ans=0; while(x)
2021-10-04 17:29:57
63
1
原创 tarjan割点《算法进阶》
代码:#include<bits/stdc++.h>using namespace std;const int SIZE=100010;int head[SIZE],ver[SIZE*2],Next[SIZE*2];int dfn[SIZE],low[SIZE],stack[SIZE];int n,m,tot,num,root;bool cut[SIZE];void add(int x,int y){ ver[++tot]=y,Next[tot]=head[x],head[x
2021-10-04 16:35:27
101
5
原创 蚯蚓的正解
文章目录前言一、正解(摘自洛谷aiyougege)二、原理(摘自洛谷大佬)总结前言真的很意外,这题代码标的是二叉堆,但是优先队列和手打堆都TLE,(大概80~90的样子),去看了一下评论区,发现正解是三队列,(这就很离谱)。一、正解(摘自洛谷aiyougege)#include<algorithm>#include<iostream>#include<cstdio>#include<queue>#include<cmath>#d
2021-10-04 16:03:58
141
3
原创 2021-10-04模拟赛总结
文章目录总括一、pandas是什么?二、使用步骤1.引入库2.读入数据总结总括一、pandas是什么?示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。二、使用步骤1.引入库代码如下(示例):import numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport warningswarnings.filterwarning.
2021-10-04 14:58:12
179
4
原创 2021-10-03 模拟赛总结
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档文章目录基本信息一、Cheese二、使用步骤1.引入库总结基本信息题数:4时间:3.5h分数:153/400来源:2017noip一、Cheese算法:BFS宽搜/并查集代码:#include<bits/stdc++.h>using namespace std;struct node{ long long x; long long y; long long z;}a[2005];long l
2021-10-03 15:55:23
158
5
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人