Seam Carving DescriptionFish likes to take photo with his friends. Several days ago, he found that some pictures of him were damaged. The trouble is that there are some seams across the pictures. So he tried to repair these pictures. He scanned these…
Battle ships Problem DescriptionDear contestant, now you are an excellent navy commander, who is responsible of a tough mission currently.Your fleet unfortunately encountered an enemy fleet near the South Pole where the geographical conditions are ne…
Comparison of Android versionsProblem DescriptionAs an Android developer, itˇs really not easy to figure out a newer version of two kernels, because Android is updated so frequently and has many branches. Fortunately, Google identifies individual bui…
Game with Pearls Problem DescriptionTom and Jerry are playing a game with tubes and pearls. The rule of the game is:1) Tom and Jerry come up together with a number K.2) Tom provides N tubes. Within each tube, there are several pearls. The number of p…
今天首次接触了图像编辑中的seam carving知识,感觉挺神奇的.虽然我自己可能理解的不是很深刻,但是记录下来,总是好的. seam carving直接翻译过来是“线裁剪”的意思.它的主要用途是对图像进行缩放.不同于传统的按比例缩放图像的方式,seam carving的是内容感知的,它充分考虑了图像中像素的重要性,通过删除或增加seam线来实现图像尺寸的调整.它在缩放不是特别大的情况下,能够很好的保护图像中的显著物体. 具体来说,seam carving定义了穿过整幅图像的像素线(即seam…
option=com_onlinejudge&Itemid=8&page=show_problem&category=648&problem=5158&mosmsg=Submission+received+with+ID+1708713">https://icpcarchive.ecs.baylor.edu/index.php? option=com_onlinejudge&Itemid=8&page=show_problem&…
编程作业二 作业链接:Seam Carving & Checklist 我的代码:SeamCarver.java 问题简介 接缝裁剪(Seam carving),是一个可以针对照片内容做正确缩放的算法(由 Shai Avidan 和 Ariel Shamir 所发表).概念上,这个算法会找出好几条 seams,而这些 seams 是在照片中最不重要的一连串像素,接着再利用这些 seams,对照片做缩放.如果是要缩小照片,则移除这些 seams,若是放大,则在这些 seams 的位置上,插入一些像…
Description  Byteman, one of the most deserving employee of The Goldmine of Byteland, is about to retire by the end of the year. The Goldmine management would like to reward him in acknowledgment of his conscientious work. As a reward Byteman may rec…
题目传送门 /* 题意:从上到下,找最短路径,并输出路径 DP:类似数塔问题,上一行的三个方向更新dp,路径输出是关键 */ #include <cstdio> #include <algorithm> #include <iostream> #include <cstring> #include <cmath> #include <string> #include <vector> #include <queue&…
Seam Carving Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 956    Accepted Submission(s): 382 Problem Description Fish likes to take photo with his friends. Several days ago, he found that so…
HDOJ 5090 水题.从小到大排序,能够填充达到符合条件的.先填充好.填充之后进行调整. 传送门:pid=5090">点击打开链接 #include <cstdio> #include <cmath> #include <queue> #include <map> #include <vector> #include <cstring> #include <algorithm> using namesp…
1.什么是TSP问题 一个售货员必须访问n个城市,这n个城市是一个完全图,售货员需要恰好访问所有城市的一次,并且回到最终的城市. 城市于城市之间有一个旅行费用,售货员希望旅行费用之和最少. 完全图:完全图是一个简单的无向图,其中每对不同的顶点之间都恰连有一条边相连. 2.TSP问题前提 回朔法:把所有的解列出来,形成一棵树,利用剪枝深度优先进行遍历,遍历的过程记录和寻找最优解.(剪枝就是把一条再深搜下去也不是最优解的分支剪去). 动态规划:把一个大问题拆分成小问题,把小问题的最优结果通过表保留,…
hihocoder 1084 : http://hihocoder.com/problemset/problem/1084 北京邀请赛 Just  String http://www.bnuoj.com/v3/problem_show.php?pid=34990 两道题同样的做法,题目基本内容是找到A的字串中和B串长度一样,且不同的字符个数不超过k个的置. 以hihocoder 1084为例, 是求有多少个A的字串的,与B串长度一样,且不同的字符个数不超过k. 分析:预处理hash,然后对每个字…
题目链接:http://acm.bnu.edu.cn/bnuoj/problem_show.php?pid=34985 题目大意:问n长度的串用0~k的数字去填,有多少个串保证任意子串中不包含0~k的某一个全排列 邀请赛上A的较多的一道题,比赛的时候死活想不出,回来之后突然就想通了,简直..... = =! 解题思路: 对于所有串我们都只考虑末尾最多有多少位能构成全排列的一部分(用l来表示),即最多有多少位不重复的数字出现,将问题转化为求末尾最多有k位能构成全排列的串的总数量 假设k为5,有一个…
这周作业设计到的算法是有向无环图的最短路径算法,只需要按照顶点的拓扑顺序去放松顶点即可.而在这个题目中拓扑顺序就是按照行的顺序或列的顺序. 用到的数据结构为一个二维数组picture同来存储每个像素的颜色,一个二维数组energy用来存储每个像素的能量.开始我是用一个Picture类的对象来存储图像,但是在讨论区里发现用二维数组存储图像,可以占用更小的存储,且计算能量.removeseam时更快更方便. 在检验各像素能量时发现计算结果不正确,后来发现是运算符优先级的问题,((rgbLeft >>…
题意,给一个数字矩阵,要求从上往下的一条路径,使这条路径上数字之和最小,如有多条输出最靠右的一条. 数字三角形打印路径... 一般打印路径有两种选择,一是转移的时候加以记录,二是通过检查dp值回溯. #include<cstdio> #include<cstring> #include<vector> using namespace std; ; ][maxn]; ][maxn]; ][maxn]; int m,n; const int INF = 1e9; void…
水题,直接上代码了 #include<cstdio> #include<cstring> #include<iostream> #include<cmath> #include<algorithm> #include<set> #include<map> #include<queue> #include<stack> #include<string> #include<vector…
题意:n个数 m个询问 每个询问[l, r]的和, 再把[l, r]之间所有的数变为平方(模为9223372034707292160LL) 很明显的线段树 看到这个模(LLONG_MAX为9223372036854775807) 很明显平方时会爆LL 很容易发现所有数平方模了几次之后值就不再改变了 而且这个“几次”相当小 因此直接暴力搞就好了 public static void main(String[] args) { Scanner in = new Scanner(System.in);…
题意: 给n和一个字符串(可以有空格) 求字符串编码n次后的字符串 编码方式:字符串的每个字符转化成ASCII码, ASCII码转化成8位2进制,    将二进制数分割成6位为一组的(不够的补0), 再变成十进制数 依次按照以下方式变成字母 转化成字母后, 若长度不是4的整数倍, 在字符串后面补= 举个例子, The的ASCII码分别为84,104,101 转成8位2进制为01010100,01101000,01100101 分割成6位的为010101,000110,100001,100101…
水 #include <stdio.h> #include <stdlib.h> #include<math.h> #include<iostream> #define LL long long using namespace std; int main() { int t; int a,b; int cas; LL sum; while(~scanf("%d",&t)) { ;i<=t;i++) { sum=; scanf…
http://acm.hdu.edu.cn/showproblem.php?pid=4848 比赛的时候我甚至没看这道题,事实上不难.... 可是说实话,如今对题意还是理解不太好...... 犯的错误: 1.floy循环次序写错, 2.搜索的时候.应该先推断i是不是能够搜(就是可不可能产生解).然后标记vis[i]=1.我二逼的先标记vis[i]=1,然后推断i是不是可搜,这样肯定会导致有些时候,cnt!=n 我的剪枝方法(2546MS AC): 搜下一个结点之前.确保时间小于全部的未訪问的结点…
A. A Matrix 点击打开链接 构造,结论是从第一行開始往下产生一条曲线,使得这条区间最长且从上到下递减, #include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <stdio.h> #include <vector> #include <set> using namespace std; #defi…
这道题 我没看出来 他只可以往下走,我看到的 8-connected :所以今天写一下如果是 8-connected 怎么解: 其实说白了这个就是从上到下走一条线到达最后一行的距离最小: 从Map[a][b] 到Map[a][b+1] 的距离是Map[a][b+1] 以此类推:建图即可: 然后在加一个点0,和n+m+1 点这样在建立一下从  0 点到第一行的边,和最后一行到(n+m+1) 的边 求一个从0 到(n+m+1) 的最短路径就好了, 怎么维护最右侧?:  Dijkstra  有 队列优…
#include <cstdio> #include <cstring> #include <iostream> using namespace std; const int M=510; int m,n; int map[M][M], match[M], chk[M]; int dfs(int p) { int i; for(i=1;i<=m;i++) if( map[p][i] && chk[i]==0 ) { chk[i]=1; if( ma…
传送门 题目描述     在空闲时间,张老师习惯性地和菜哭武玩起了取石子游戏,这次的游戏规则有些不同,在他们面前有n堆石子,其中,第i堆石子的个数为a[i],现在制定规则如下:     从张老师开始,两个人轮流取石子,每次可以从任意一堆中取走x个石子,其中x必须严格小于这堆石子的总数并且能够被这堆石子的个数整除,谁先无法继续取走石子就算失败!     例如,只有一堆石子,个数为6,张老师首先可以取走的石子个数为1,2或者3个.     现在给定n堆石子每一堆的石子数,张老师希望你帮他确定在双方最…
题目大意:给你L到N的范围,要求你求这个范围内的所有整数的立方和. Sample Input2 //T1 32 5 Sample OutputCase #1: 36Case #2: 224 # include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <cmath> # define LL long long using na…
题意是给你一棵树    n个点 n-1条边   起点是1   每一个点都有权值 每次能从根节点走到叶子节点   经行k次游戏 每次都是从1開始    拿过的点的权值不能拿第二次   问最大权值和. 開始看到题时也没想到什么方法  就依照常规的来  结果超时了   试着优化了好多次  最后过了   百度题讲解是树链剖分    醉了    还没学! .. 说说我的做法吧    map[i]=a表示i节点的跟节点为a节点   从全部叶子节点開始入队(有点队列里有三个变量  各自是节点编号  权值  深…
题意: 给一个m*n的矩阵,每格上有一个数. 找从第1行到第m行的一条路径,使得这条路径上的数之和最小. 路径必须满足相邻两行所选的两个数的纵坐标相邻(即一个格子必须是另一个格子的周围八个格子中的一个) 输出每一行取的数的列值.  若有多个答案,则路径要求尽量靠右. 思路: 简单数塔DP.题比较不好读,不过可以分析样例. 代码: int T,m,n; int a[105][105], f[105][105]; int path[105]; int main(){ cin>>T; rep(t,1…
2017-08-31 16:19:30 writer:pprp 这道题快要卡死我了,队友已经告诉我思路了,但是做题速度很缓慢,很费力,想必是因为之前 的训练都是面向题解编程的缘故吧,以后不能这样了,另外这几天要学习一下动态规划, 先普及两个小知识点,这个点很简单很简单但是却卡了我很久很久, 现在作为模板记录下来: 1.将二进制数转化为十进制数 //转化为十进制 //test:ok ll twoTen(int a[]) { ll ans = ; ; i < N ; i++) { ans += (…
Problem Description Nike likes playing cards and makes a problem of it. Now give you n integers, ai(1≤i≤n) We define two identical numbers (eg: 2,2) a Duizi, and three consecutive positive integers (eg: 2,3,4) a Shunzi. Now you want to use these inte…