随笔分类 -  算法

摘要:LINK 题意:有1个产品,m个步骤编号为1~m。步骤要在n个机器人的手中生产完成。其中,第i个步骤在第j个机器人手中的生产时间给定为$T[i][j]$,切换机器人消耗cost。步骤必须按顺序,同一个机器人不能连续完成超过l个步骤。求完成所有步骤的最短时间是多少。其中$m<=10^5$,$n<=5$ 阅读全文
posted @ 2017-07-20 18:18 Lweleth 阅读(255) 评论(0) 推荐(0)
摘要:http://codeforces.com/contest/617/problem/E 题意:给出q个查询,每次询问区间内连续异或值为k的有几种情况。 思路:没有区间修改,而且扩展端点,减小端点在前缀和的处理下都是O(n)的,使用莫队算法,每次移动区间时,注意计数是否先减. 阅读全文
posted @ 2016-12-09 22:19 Lweleth 阅读(187) 评论(0) 推荐(0)
摘要:http://www.lydsy.com/JudgeOnline/problem.php?id=2038 题意:多次询问区间内取出两个相同颜色的种类数 思路:由于不是在线更新,那么可以进行离线查询,而且当知道了[l,r]的答案,且能在O(1)的条件下得知[l-1,r],[l+1,r],[l,r+1] 阅读全文
posted @ 2016-12-08 23:01 Lweleth 阅读(226) 评论(0) 推荐(0)
摘要:这题作为模板题,解法好多... 最近周围的人都在搞图论阿,感觉我好辣鸡,只会跟风学习。 暂时只有SPFA和Dijkstra的 SPFA (邻接表版。也可以写成临接矩阵存图,但题目可能给出平行边的,所以要注意找最小的边储存,还要注意判断一个点是否多次进入队列)老实说觉得SPFA好像只是被队列优化过的f 阅读全文
posted @ 2016-06-26 21:38 Lweleth 阅读(210) 评论(0) 推荐(0)
摘要:Description An 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 阅读全文
posted @ 2016-05-17 12:23 Lweleth 阅读(377) 评论(0) 推荐(0)
摘要:Description N students were invited to attend a party, every student has some friends, only if someone’s all friends attend this party, this one can a 阅读全文
posted @ 2016-05-17 12:09 Lweleth 阅读(217) 评论(0) 推荐(0)
摘要:Given a list of N integers A1, A2, A3,...AN, there's a famous problem to count the number of inversions in it. An inversion is defined as a pair of in 阅读全文
posted @ 2016-05-01 22:28 Lweleth 阅读(444) 评论(1) 推荐(0)
摘要:Problem Description Read the program below carefully then answer the question.#pragma comment(linker, "/STACK:1024000000,1024000000")#include <cstdio> 阅读全文
posted @ 2016-04-08 21:28 Lweleth 阅读(282) 评论(0) 推荐(0)
摘要:Jzzhu has invented a kind of sequences, they meet the following property: You are given x and y, please calculate fn modulo 1000000007 (109 + 7). Inpu 阅读全文
posted @ 2016-04-06 20:35 Lweleth 阅读(221) 评论(1) 推荐(0)
摘要:Description A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) ar 阅读全文
posted @ 2016-04-05 23:44 Lweleth 阅读(248) 评论(0) 推荐(0)
摘要:<!-- 正文内容 --> 问题描述 给你三个数a,b,c,求a的b次的前c位数(不够c位输出全部即可) 输入 输入数据有多组,每组占一行,有三个整数,之间有空格。(0<a,b<2147483648,0<c<10) 输出 对于每组输入数据,输出一行. 样例输入 55 20 6 10 5 2 样例输出 阅读全文
posted @ 2016-04-02 15:27 Lweleth 阅读(217) 评论(0) 推荐(0)
摘要:原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=3068 Problem Description 给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度.回文就是正反读都是一样的字符串,如aba, abba等 Input 输 阅读全文
posted @ 2016-04-02 13:31 Lweleth 阅读(567) 评论(0) 推荐(0)