白书
文章平均质量分 65
h1021456873
这个作者很懒,什么都没留下…
展开
-
UVO 120 Stacks of Flapjacks (整行输入+构造函数)
DescriptionBackgroundStacks and Queues are often considered the bread and butter of data structures and find use in architecture, parsing, operating systems, and discrete event simulation.原创 2015-08-26 15:58:01 · 612 阅读 · 0 评论 -
归并排序_分治算法 (白书P226)
#include#include#includeusing namespace std;int a[100],ans[100];void merge_sort(int x,int y){ if(y-x>1) { int mid=x+(y-x)/2; merge_sort(x,mid); merge_sort(mid,y); int i=x,j=mid; int n原创 2015-08-22 17:00:01 · 628 阅读 · 0 评论 -
增量构造法 (白书P188)
#include#includeusing namespace std;int ans[6];int n;void dfs(int cnt){ int i,j; for(i=0;i<cnt;i++) cout<<ans[i]<<" "; if(cnt) cout<<endl; int s=cnt?ans[cnt-1]+1:0; for(i=s;i<n;i++) { an原创 2015-08-20 11:38:10 · 1670 阅读 · 0 评论 -
UVa 10954 Add All (石子合并_优先队列)
#include#include#include#includeusing namespace std;priority_queue,greater >qq;int main(){ int sum,i,j,num,n,ans; while(cin>>n && n) { for(i=0;i<n;i++) { cin>>num; qq.push(num); }原创 2015-09-04 19:50:03 · 587 阅读 · 1 评论 -
UVa 12627 Erratic Expansion 奇怪的气球膨胀 (分治_递归) 白书P245
Piotr found a magical box in heaven. Its magic power is that if you place any red balloon inside it then, after one hour, it will multiply to form 3 red and 1 blue colored balloons. Then in the next h原创 2015-09-04 17:41:56 · 601 阅读 · 1 评论 -
UVa 714 Copying Books (最大值尽量小_二分+贪心)
原题:Before the invention of book-printing, it was very hard to make a copy of a book. All the contents had to be re-written by hand by so called scribers. The scriber had been given a book and原创 2015-09-04 15:35:04 · 501 阅读 · 1 评论 -
八皇后问题 (白书P192)
#include#include#includeusing namespace std;int a[20],ans,n;void dfs(int cnt){ if(cnt==n) { ans++; return ; } for(int i=0;i<n;i++) { int ok=1; a[cnt]=i; for(int j=0;j<cnt;j++) {原创 2015-08-20 18:24:25 · 613 阅读 · 0 评论 -
位向量法 (白书P188)
#include#include#includeusing namespace std;int ans[6],n;void dfs(int cnt){ int i,j; if(cnt==n) { for(i=0;i<n;i++) if(ans[i]) cout<<i<<" "; cout<<endl; return ; } ans[cnt]=1; dfs(cnt原创 2015-08-20 12:04:21 · 672 阅读 · 0 评论 -
uva 11093 Just Finish it up (环形跑道水题_模拟)
题目大意:就是环形的路上,路上有n个加油站,每个加油站可以加一定量的油pi,到达下一个加油站需要消耗qi升油,现在问可以从出发点驶出然后能够到达起点的出发点序号最小是多少,如果不可能输出不可能。#include#include#includeusing namespace std;const int maxn=101001;int a[maxn],b[maxn];int mai原创 2015-09-04 20:26:14 · 517 阅读 · 2 评论 -
POJ 2823 Sliding Window(滑动窗口问题__优先队列||单调队列)
DescriptionAn array of size n ≤ 106 is given to you. There is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the wi原创 2015-09-03 00:04:53 · 783 阅读 · 1 评论 -
滑动窗口_单调队列入门 (白书P241)
#include #include using namespace std;#define MAX 1000001int A[MAX]; //存储数据int Q[MAX]; //队列int P[MAX]; //存储A[i]中的下标iint Min[MAX]; //输出最小int Max[MAX]; //输出最大int n,k;void get_min(){原创 2015-09-03 16:42:35 · 458 阅读 · 1 评论 -
UVa 传说中的车(白书P11134_放棋子+set)
题意: 给你一个n*n的棋盘,让你在棋盘上放n个棋子,要求是所有棋子不能相互攻击(同行或者同列就会攻击),并且每个棋子都有一个限制,那就是必须在给定的矩形r[i]里,输出每个棋子的位置,special Jude。思路: 看完后第一反应就是匈牙利(哎!惭愧啊。)结果想着怎么建图,想了一会呵呵了,果断想别的方法,其实这个题目设计到一个小思想非常好,那就是把整体分原创 2015-09-03 16:12:43 · 541 阅读 · 1 评论 -
UVa 11054 - Wine trading in Gergovia (等价转化_水题吧)
【原题】As you may know from the comic "Asterix and the Chieftain's Shield", Gergovia consists of one street, and every inhabitant of the city is a wine salesman. You wonder how this economy works原创 2015-09-01 16:34:25 · 460 阅读 · 1 评论 -
UVa 11572 - Unique Snowflakes (滑动窗口STL_map||set) 好题!!!
题目大意:给n个数, nset容器的新技能get√#include#include#include#include#includeusing namespace std;const int maxn=1e6+100;int a[maxn];int main(){ int t,n,i,j; setset; cin>>t; while(t-原创 2015-09-01 19:21:32 · 899 阅读 · 1 评论 -
uva 1152 4 Values whose Sum is 0(二分_中途相遇|| hash)
#include#include#include#includeusing namespace std;const int maxn=1e5+100;struct node{ int index; int num; int book;} a[maxn];bool cmp(node x,node y){ if(x.num<y.num) return true; el原创 2015-08-28 16:40:48 · 460 阅读 · 0 评论 -
uva 437 The Tower of Babylon (DAG_变形 ,dp)
Perhaps you have heard of the legend of the Tower of Babylon. Nowadays many details of this tale have been forgotten. So now, in line with the educational nature of this contest, we will tell you the原创 2015-10-02 12:56:42 · 363 阅读 · 0 评论