随笔分类 -  数据结构

摘要:struct node{ int next[27]; int v; void init() { v=0; memset(next,-1,sizeof(next)); }};node L[1000500];int tot=0;void add(... 阅读全文
posted @ 2015-08-15 09:56 sola94 阅读(159) 评论(0) 推荐(0)
摘要:#include#include#include#include#includeusing namespace std;int mat[200][200];int ran[200];int main(){ int n,m; int i,j,k; int f,t; while(... 阅读全文
posted @ 2015-08-12 19:42 sola94 阅读(134) 评论(0) 推荐(0)
摘要:#include#include#include#include#includeusing namespace std;char str[300];double ans;double chcd(char x){ return (x-'0')*1.0;}double ch(int l,int r... 阅读全文
posted @ 2015-07-26 23:14 sola94 阅读(112) 评论(0) 推荐(0)
摘要:#include#include#include#include#include#include#includeusing namespace std;vector a[100000+100];map temp;int h[100000+100];int shoot[100000+100];int... 阅读全文
posted @ 2015-07-08 16:02 sola94 阅读(121) 评论(0) 推荐(0)
摘要:#include#include#include#includeusing namespace std;int ch[30000][30];int val[30000][30];char str[1000+10][20+10];int sz;int idx(char c) {return c-'a'... 阅读全文
posted @ 2015-07-03 01:01 sola94 阅读(103) 评论(0) 推荐(0)
摘要:#include#include#include#include#include#includeusing namespace std;#define MAXN 100000+10int n,st[MAXN],cnt,a[MAXN],kill[MAXN]={0},f[MAXN]={0};int ma... 阅读全文
posted @ 2015-05-19 21:34 sola94 阅读(233) 评论(0) 推荐(0)
摘要:题意: 一共有n天 每天西瓜售价为dp[i]元 该天的西瓜能吃v[i]天 而且这天如果买了西瓜之前的西瓜就要扔掉 问每天都吃到西瓜的最小花费是多少思路: 从最后一天开始dp最小花费 并用线段树单点更新来维护#include #include #include #include using names... 阅读全文
posted @ 2015-04-15 20:42 sola94 阅读(168) 评论(0) 推荐(0)
摘要:题意:给出n个宽度为1 高度为hi的长方形 问能圈出的最大长方形面积多大思路:http://blog.csdn.net/dgq8211/article/details/7740610#include#include#include#include#includeusing namespace ... 阅读全文
posted @ 2015-04-06 15:29 sola94 阅读(83) 评论(0) 推荐(0)
摘要:#include#include#include#include#includeusing namespace std;char str[20];int main(){ int n; int len,ans; int s1,s2; int i,j,k; while(sc... 阅读全文
posted @ 2015-03-26 16:46 sola94 阅读(175) 评论(0) 推荐(0)
摘要:#include #include #include #include #include using namespace std;const int N = 111111;int topo[205];struct node{ char a[105];}e[105];int n;int g[30... 阅读全文
posted @ 2015-03-07 01:33 sola94 阅读(213) 评论(0) 推荐(0)
摘要:#include#include#include#include#include#include#includeusing namespace std;int t,n;int main(){ int i,j,k; cin>>t; char op[10],io[10]; whi... 阅读全文
posted @ 2015-02-18 00:37 sola94 阅读(138) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=3468题意 :对于一个序列有两种操作 1 查询 l到r 的和 2 对于l 到r上的每个数 加上 up思路: 用单点更新必然超时 所以需要区间更新(位运算时 注意 m-m>>1 与 m-(m>>1) 的区别)#include#inclu... 阅读全文
posted @ 2015-02-03 22:39 sola94 阅读(140) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1754照着hdu 1166 的模板稍加改动即可#include#include#include#includeusing namespace std;int sum[1000000];void push(int r... 阅读全文
posted @ 2015-02-02 17:05 sola94 阅读(126) 评论(0) 推荐(0)
摘要:http://acm.neu.edu.cn/hustoj/problem.php?cid=1047&pid=4题意:数字1到n 任意排列 求排列成有序序列最少交换次数思路:求最小交换次数有两种 1 交换的两数必须相邻 (poj 2299) 通过归并排序求出其逆序数即为所求值 ... 阅读全文
posted @ 2015-02-01 14:49 sola94 阅读(533) 评论(0) 推荐(0)
摘要:算法入门经典 训练指南 p189#include#include#include#include#includeusing namespace std;struct Item{ int s,b; Item(int s,int b) :s(s),b(b) {} bool operat... 阅读全文
posted @ 2015-01-30 16:04 sola94 阅读(158) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1272这题要求任意两个房间都相通又不能有环即通过并查集求出是否构成最小生成树#include#include#include#includeusing namespace std;#define maxn 1000... 阅读全文
posted @ 2015-01-30 12:32 sola94 阅读(194) 评论(0) 推荐(0)
摘要:题意 :交换相邻的两个数来排序 最少交换几次思路:题意可以转化成求 数列中存在几个逆序数可以看作冒泡排序 但是复杂度过高 可以用归并排序 和离散化的树状数组来完成(注意 n#include#include#includeusing namespace std;int a[5000000+100];i... 阅读全文
posted @ 2015-01-29 20:46 sola94 阅读(153) 评论(0) 推荐(0)
摘要:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1136#include#include#include#include#includeusi... 阅读全文
posted @ 2015-01-29 11:31 sola94 阅读(111) 评论(0) 推荐(0)
摘要:其实这题可以直接用vector#include#include#include#include#include#includeusing namespace std;vector str[1000000+100];int main(){ int n,m; int i,j,k; in... 阅读全文
posted @ 2015-01-29 01:02 sola94 阅读(137) 评论(0) 推荐(0)
摘要:用数组模拟栈#include#include#include#includeusing namespace std;char str1[30],str2[30];int sta[30];int main(){ int n; int i,j,k; int ans[100]; w... 阅读全文
posted @ 2015-01-29 00:48 sola94 阅读(114) 评论(0) 推荐(0)