2017年4月19日

Gym - 100187J J - Deck Shuffling —— dfs

摘要: 题目链接:http://codeforces.com/gym/100187/problem/J 题目链接:问通过洗牌器,能否将编号为x的牌子转移到第一个位置? 根据 洗牌器,我们可以知道原本在第i位置的牌可以转移到第j个位置,且这种转移是单向的。如果要把在某个位置的牌转移到第一个位置,那么必须至少存 阅读全文

posted @ 2017-04-19 22:11 h_z_cong 阅读(166) 评论(0) 推荐(0) 编辑

Gym - 100187E E - Two Labyrinths —— bfs

摘要: 题目链接:http://codeforces.com/gym/100187/problem/E 题解:一开始做的时候是将两幅图合并,然后直接bfs看是否能到达终点。但这种做法的错的,因为走出来的路对于两幅图来说不一定都是最短的。正确做法: 第一步:分别用bfs求出两图的最短路。 第二步:如果最短路长 阅读全文

posted @ 2017-04-19 21:20 h_z_cong 阅读(216) 评论(0) 推荐(0) 编辑

Gym - 100187A A - Potion of Immortality —— 贪心

摘要: 题目链接:http://codeforces.com/gym/100187/problem/A题解:光题意就想了很久:在最坏情况下的最小兔子数。其实就是至少用几只兔子就一定能找出仙药(答案存在的话)。再注意一下特殊情况就可以了,代码如下:#include #inclu... 阅读全文

posted @ 2017-04-19 21:11 h_z_cong 阅读(142) 评论(0) 推荐(0) 编辑

Gym - 100283F F. Bakkar In The Army —— 二分

摘要: 题目链接:http://codeforces.com/gym/100283/problem/F F. Bakkar In The Army time limit per test 2 seconds memory limit per test 256 megabytes input army.in 阅读全文

posted @ 2017-04-19 20:52 h_z_cong 阅读(349) 评论(0) 推荐(0) 编辑

2017年4月14日

2016 Al-Baath University Training Camp Contest-1 I. March Rain —— 二分

摘要: 题目链接:http://codeforces.com/problemset/gymProblem/101028/I I. March Rain time limit per test 2 seconds memory limit per test 64 megabytes input standar 阅读全文

posted @ 2017-04-14 23:27 h_z_cong 阅读(253) 评论(0) 推荐(0) 编辑

2017广东工业大学程序设计竞赛 E倒水(Water)

摘要: 题目链接:http://www.gdutcode.sinaapp.com/problem.php?cid=1057&pid=4题解:方法一:对n取2的对数:取对数的公式:s = log(n)/log(2), //取整#include#include#include#i... 阅读全文

posted @ 2017-04-14 22:40 h_z_cong 阅读(171) 评论(0) 推荐(0) 编辑

2017年4月7日

Codeforces Round #398 (Div. 2) C. Garland —— DFS

摘要: 题目链接:http://codeforces.com/contest/767/problem/C 题解:类似于提着一串葡萄,用剪刀剪两条藤,葡萄分成了三串。问怎样剪才能使三串葡萄的质量相等。 首先要做的就是统计葡萄的总质量tot。之后就是找到两子串质量为(tot/3)的葡萄(如果除不尽,则必定找不到 阅读全文

posted @ 2017-04-07 23:08 h_z_cong 阅读(153) 评论(0) 推荐(0) 编辑

2017年4月5日

Codeforces Round #371 (Div. 2) C. Sonya and Queries —— 二进制压缩

摘要: 题目链接:http://codeforces.com/contest/714/problem/CC. Sonya and Queriestime limit per test1 secondmemory limit per test256 megabytesinput... 阅读全文

posted @ 2017-04-05 16:13 h_z_cong 阅读(172) 评论(0) 推荐(0) 编辑

2017年4月2日

CSU1808 地铁 —— dijkstra变形

摘要: 题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1808 题解:由于中转线路需要花费一定的时间,所以一般的以顶点为研究对象的dijkstra算法就不适用了,因为在松弛过程中,当前节点的最短路径不能知道是从那条线路过来的。(保存当前结点的 阅读全文

posted @ 2017-04-02 21:38 h_z_cong 阅读(327) 评论(0) 推荐(0) 编辑

Codeforces Round #222 (Div. 1) Maze —— dfs(连通块)

摘要: 题目链接:http://codeforces.com/problemset/problem/377/A 题解: 有tot个空格(输入时统计),把其中k个空格变为wall,问怎么变才能使得剩下的空格依然为连通的。把问题反过来,其实就是求tot-k的连通图。dfs:在搜索过的空格中做个标记,同时更新连通 阅读全文

posted @ 2017-04-02 21:31 h_z_cong 阅读(207) 评论(0) 推荐(1) 编辑

HDU3183 A Magic Lamp —— 贪心(单调队列优化)/ RMQ / 线段树

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3183 题解: 方法一:贪心。 在草稿纸上试多几次可以知道,删除数字中从左到右最后一位递增(可以等于)的数字,可以得到最小值,在这个基础下,又继续删除最后一位递增的数字,得到的依然是最小值。这就表明当前这 阅读全文

posted @ 2017-04-02 21:15 h_z_cong 阅读(315) 评论(0) 推荐(0) 编辑

2017年3月30日

POJ2559 Largest Rectangle in a Histogram —— 单调栈

摘要: 题目链接:http://poj.org/problem?id=2559 Largest Rectangle in a Histogram Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 24259 Accepted: 7844 D 阅读全文

posted @ 2017-03-30 15:56 h_z_cong 阅读(186) 评论(0) 推荐(0) 编辑

Gym - 100676F Palindrome —— 并查集

摘要: 题目链接:https://vjudge.net/contest/155789#problem/E 题解: 由于是回文串,所以可以先将在对称位置的字符放在同一个集合(如果期间有两个非‘?’,且不相等,则退出操作。并跳过之后的某些步骤。注意输入不能跳过)。然后再接收输入的限制条件,进行并查集。有两种并查 阅读全文

posted @ 2017-03-30 15:17 h_z_cong 阅读(233) 评论(0) 推荐(0) 编辑

2017年3月27日

UVALive - 4867 —— dp

摘要: 题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2868用暴力也过了:#include#includ... 阅读全文

posted @ 2017-03-27 22:13 h_z_cong 阅读(204) 评论(0) 推荐(0) 编辑

POJ2389 —— 高精度乘法

摘要: 直接上代码了:#include#include#include#include#include#include#include#include#include#include#define LL long long#define MAX(a,b) (a>b?a:b)#... 阅读全文

posted @ 2017-03-27 21:58 h_z_cong 阅读(168) 评论(0) 推荐(0) 编辑

导航