cf 442 D. Olya and Energy Drinks】的更多相关文章

cf 442 D. Olya and Energy Drinks(bfs) 题意: 给一张\(n \times m(n <= 1000,m <= 1000)\)的地图 给出一个起点和终点,每秒钟可以沿着四个方向直走\(1\)到$k(k <= 1000) $步,问从起点到终点最少需要多少秒 思路: 最暴力的\(bfs\)时间复杂度为\(O(n * m * k)\) 由bfs可以知道,每个点只需要被访问过一点就已经是最短了,也即访问过一次就可以将其从地图中删去了 这里有两种方法可以来实现 1…
http://codeforces.com/contest/877/problem/D   D. Olya and Energy Drinks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Olya loves energy drinks. She loves them so much that her room is fu…
D. Olya and Energy Drinks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Olya loves energy drinks. She loves them so much that her room is full of empty cans from energy drinks. Formally,…
题目链接:http://codeforces.com/contest/877/problem/D D. Olya and Energy Drinks time limit per test2 seconds memory limit per test256 megabytes Olya loves energy drinks. She loves them so much that her room is full of empty cans from energy drinks. Formal…
[链接] 我是链接,点我呀:) [题意] 给一张二维点格图,其中有一些点可以走,一些不可以走,你每次可以走1..k步,问你起点到终点的最短路. [题解] 不能之前访问过那个点就不访问了.->即k那一层循环直接break; 因为可能出现这种 ax aa aa 然后起点是(3,2)终点是(1,1);然后k=3 bfs的时候,第一步,走到了(2,2)和(3,1); 但是接下来,如果(2,2)先走的话,就会先走到(2,1); 而(3,1)认为(2,2)走过了,就不往下走了. ->但实际上他可以一步走到…
cf 442 div2 F. Ann and Books(莫队算法) 题意: \(给出n和k,和a_i,sum_i表示前i个数的和,有q个查询[l,r]\) 每次查询区间\([l,r]内有多少对(i,j)满足l <= i <= j <= r 且 sum[j] - sum[i-1] = k\) 思路: 区间左右端点的挪动对答案的贡献符合加减性质,直接用莫队算法即可 复杂度\(O(n * sqrt(n) * log(maxsum))\) 过高 考虑先离散化预处理出所有位置 将\(log\)去…
A 判断下5个名字出现了几次.pre数据巨弱,就这么一水题在std测刷掉了非常多的人.. /** @Date : 2017-10-24 16:04:41 * @FileName: A.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : $Id$ */ #include <bits/stdc++.h> #define LL lo…
A. Alex and broken contest time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems…
A. Alex and broken contest 题意 判断一个字符串内出现五个给定的子串多少次. Code #include <bits/stdc++.h> char s[110]; using namespace std; typedef long long LL; char* rec[5] = {"Danil", "Olya", "Slava", "Ann", "Nikita"}; i…
本文转自:http://net.tutsplus.com/tutorials/other/speeding-up-websites-with-yslow/ We all know there are countless reasons why web page load-times skyrocket, however, pinpointing the problem may be costly in both time and money. So why waste the effort wh…