ACM
zem_nezer
这个作者很懒,什么都没留下…
展开
-
POJ3050(DFS)
一定要根据数据规模想问题,这题数据规模就不大,时间复杂度大概是O(R*C*dir^step) = O(5*5*4^6)。规模不大,可以无脑DFS,还是这句话,先将简单的写出来再说。//#define LOCAL#include #include #include #include #define SIZE 5using namespace std;int map[SIZ原创 2018-02-01 06:12:44 · 162 阅读 · 0 评论 -
POJ2393(贪心)
水题,compare current storing value and the price of that day, if cheaper then assign, if not then update the store value.//#define LOCAL#include <cstdio>#include <cstring>#include <...原创 2018-02-28 00:15:13 · 207 阅读 · 0 评论 -
POJ3069(贪心)
贪心,自己太想当然了,直接 left + 2 * R, 这当然是不对的。。你咋知道left+R 一定有点呢。。//#define LOCAL#include <cstdio>#include <cstring>#include <algorithm>#define N 1000using namespace std;int main(voi...原创 2018-02-08 12:24:12 · 146 阅读 · 0 评论 -
POJ2376(贪心)
参考:http://blog.csdn.net/v5zsq/article/details/46828461还是之前的技巧没有弄熟,在遇到这种直到满足某一条件时再进行改变时,就应该要想到用while, 方便而且思路清晰。从这里可以看出逻辑还是不够清楚,边界条件还是拿捏的不好。//#define LOCAL#include <cstdio>#include <cs...原创 2018-02-15 03:01:31 · 259 阅读 · 0 评论 -
POJ3187(next_permutation)
一开始先用最简单的试试,实在是TLE再想其他办法。不要一直觉得总有公式可以写//#define LOCAL#include #include #include #define SIZE 10using namespace std;int main(){#ifdef LOCAL freopen("data.in", "r", stdin);#endif原创 2018-01-30 11:37:48 · 213 阅读 · 0 评论 -
POJ2718(穷举,贪心)
参考地址一开始连题意都没搞懂就开始直接做,too young。应该静下来用5分钟分析,by the way, may be the typical usage of brute-force is “void” function instead of function with return value.//#define LOCAL#include #include #incl原创 2018-01-29 13:18:32 · 215 阅读 · 0 评论 -
AOJ0121(Seven Puzzle, BFS+Cantor+逆向思维)
参考 康托展开自己真的一点头绪都没有,根据前面的大神博客自己几乎100%复制了一个,但是还是WA,觉得还是出在选方向时的判断上面。Cantor感觉这个可以作为模板,状态压缩的一个思路。还有就是BFS特点: 1.从一个起点到一个终点 2.起点和终点可以互相到达,双向的//#define LOCAL#include #include #include #include原创 2018-01-29 06:45:02 · 232 阅读 · 0 评论 -
POJ3669(meteor shower, BFS)TLE
when initial, try to convenient for later operation, e.g: if step[][] = -1, will hard to compare mini with other. However, my code still TLE for unknown reason.#define LOCAl#include #include转载 2018-01-29 03:35:27 · 153 阅读 · 0 评论 -
AOJ0558(cheese, BFS)
typical BFS usage: first use 2 array, one for record map, the other for shortest path/flag visit.BFS feature: the shortest path from one to the other, just one point!!!!(单源路)//#define LOCAL#原创 2018-01-29 03:29:32 · 207 阅读 · 0 评论 -
POJ3009(Curling 2.0, DFS)
while的使用,when aware of next step status, use “while” to deal with it. 转载地址#include #include const int dh[4]={-1, 0, 1, 0}; const int dw[4]={0, -1, 0, 1}; char map[24][24]; int w, h, _转载 2018-01-29 03:26:10 · 147 阅读 · 0 评论 -
POJ1979(Red and Black, DFS)
注意char处理, when need to manipluate inputs, take care of previous chars, such as ‘\n’ #define LOCAL#include #include #include #define SIZE 30using namespace std;char map[SIZE][SIZE];int dir原创 2018-01-29 03:22:45 · 136 阅读 · 0 评论 -
POJ1852(Ant)
很久没写了,第一个程序。 注意每个case前都要初始化//#define LOCAL#include #include #include using namespace std;int main(){#ifdef LOCAL freopen("data.in", "r", stdin); //freopen("datd.out", "w", stdout)原创 2018-01-29 02:12:55 · 158 阅读 · 0 评论 -
POJ3253(贪心)
1.要考虑到规模为20,000 累加起来肯定会超的,要用long long 2. 思想就是先从正着推,一定是先切掉最长的那块,这样之后都不会受影响;再反着来想,就是先合并最小的//#define LOCAL#include <cstdio>#include <cstring>#include <algorithm>#include <que...原创 2018-02-09 06:50:50 · 163 阅读 · 0 评论 -
POJ3617(贪心)
没啥好说的,书上原题,比较坑就是输出需要每80个换行。//#define LOCAL#include #include #include #define SIZE 2000using namespace std;int main(void){#ifdef LOCAL freopen("data.in", "r", stdin);#endif char原创 2018-02-01 12:24:31 · 106 阅读 · 0 评论 -
AOJ0525(bitset, 穷举)
这题有3点要注意: 1. the flip order is not related to result. 2. why we can simply count to maximum of number each column? Imagine only manipulate the row, it is easy to understand that it is unnece原创 2018-02-01 06:29:36 · 153 阅读 · 0 评论 -
POJ31900(贪心)
想对了一半,还是不扎实原本想将初始化和之后处理一起放到for里面的(i.e. 将push, ans = 1等放到for里面),发现比较麻烦,然后死磕这个,要建函数什么的,看了人家的代码之后发现没有必要,当然是美观了一点。其实能不能将初始化和处理一起写最重要的是看你的思路 is clear or not, sometimes it can unified. But in this case, ...原创 2018-02-17 07:29:49 · 163 阅读 · 0 评论