摘要: 一开始的做法 考虑不全面 线段树+贪心 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; const int maxn = 2e5 + 10; typed 阅读全文
posted @ 2020-07-23 22:20 wansheking 阅读(96) 评论(0) 推荐(0)
摘要: 棋盘问题 poj - 1321 #include<cstdio> using namespace std; int n, k; int ans = 0; int pic[10][10]; int cc[10]; void dfs(int r, int c, int num, int flag){// 阅读全文
posted @ 2020-07-19 16:58 wansheking 阅读(91) 评论(0) 推荐(0)
摘要: 初学 用数组来建树 // 用数组模拟 一般优于结构体 #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<string> using namespace std; const int m 阅读全文
posted @ 2020-07-13 00:06 wansheking 阅读(21) 评论(0) 推荐(0)
摘要: 初学kmp //所以,如果文本串的长度为n,模式串的长度为m,那么匹配过程的时间复杂度为O(n), //算上计算next的O(m)时间,KMP的整体时间复杂度为O(m + n)。 /*#include<cstdio> #include<algorithm> #include<cstring> usi 阅读全文
posted @ 2020-07-12 01:03 wansheking 阅读(22) 评论(0) 推荐(0)
摘要: 埃氏筛 inline void get_prime(){ bool limit[N]; limit[0]=limit[1]=true; for(int i=2;i<=n;i++){ if(!limit[i]){ prime[++cnt]=i; for(int j=i*2;j<=n;j+=i) lim 阅读全文
posted @ 2020-07-08 23:46 wansheking 阅读(43) 评论(0) 推荐(0)
摘要: dijkstra算法 #include<stdio.h> int map[205][205]; int vis[205],len[205]; const int MAX=0xfffffff; int main() { int N,M; int a,b,x; int s,t; while(scanf( 阅读全文
posted @ 2020-07-06 23:57 wansheking 阅读(45) 评论(0) 推荐(0)
摘要: 快速幂 ll qpow(ll x, ll y, ll mod){ ll ret = 1; while(y){ if(y & 1) ret = (ret % mod * x % mod) % mod; x = (x % mod * x % mod); y >>= 1; } return ret; } 阅读全文
posted @ 2020-07-03 09:45 wansheking 阅读(43) 评论(0) 推荐(0)
摘要: 二分图: 二分图又称作二部图,是图论中的一种特殊模型。 设G=(V,E)是一个无向图,如果顶点V可分割为两个互不相交的子集(A,B),并且图中的每条边(i,j)所关联的两个顶点i和j分别属于这两个不同的顶点集(i in A,j in B),则称图G为一个二分图。 简单的说,一个图被分成了两部分,相同 阅读全文
posted @ 2020-05-16 22:23 wansheking 阅读(262) 评论(0) 推荐(0)
摘要: 以HDU-3068为例 题目: 给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度.回文就是正反读都是一样的字符串,如aba, abba等 Input: 输入有多组case,不超过120组,每组输入为一行小写英文字符a,b,c...y,z组成的字符串S两组case之 阅读全文
posted @ 2020-05-16 18:28 wansheking 阅读(428) 评论(0) 推荐(0)