[BZOJ4099]Trapped in the Haybales Gold Description Farmer John has received a shipment of N large hay bales (1≤N≤100,000), and placed them at various locations along the road leading to his barn. Unfortunately, he completely forgets that Bessie the c…
题目如下: In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cel…
Santa Claus and a Palindrome Time Limit: 20 Sec  Memory Limit: 512 MB Description 有k个串,串长都是n,每个串有一个ai的贡献. 选出若干个串,若它们可以通过任意组合,形成一个回文串,则可以获得它们的贡献之和. 求最大贡献. Input 第一行两个整数k,n. 之后k行,每行分别是一个串si,与贡献ai. Output 一个整数表示答案. Sample Input 7 3 abb 2 aaa -3 bba -1 z…
题目 题目     分析 第一次用stringstream,真TMD的好用     代码 #include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; getchar();//回车 while(n--) { string s1,s2; getline(cin,s1); getline(cin,s2); for(int i=0;i<s1.length();i++) if(!isalpha(s1…
1.vector 动态数组,方便的动态扩容,方便的变量初始化(int类型默认初始化为0,bool默认初始化为false),可以用来实现邻接表(结点数太多的图). 头文件 #include<vector> using namespace std; 定义 //typename 可以是基本数据类型,可以是其它标准stl容器,可以是自定义结构体 vector<typename> name; vector<int> v1; vector<vector<int>…
[题目链接]:https://vijos.org/p/category/%E5%85%B6%E4%BB%96,%E4%BA%8C%E5%88%86%E6%9F%A5%E6%89%BE 描述 一个快递公司要将n个包裹分别送到n个地方,并分配给邮递员小K一个事先设定好的路线,小K需要开车按照路线给的地点顺序相继送达,且不能遗漏一个地点.小K得到每个地方可以签收的时间段,并且也知道路线中一个地方到下一个地方的距离.若到达某一个地方的时间早于可以签收的时间段,则必须在这个地方停留至可以签收,但不能晚于签…
[BZOJ4101][Usaco2015 Open]Trapped in the Haybales (Silver) Description Farmer John has received a shipment of N large hay bales (1≤N≤100,000), and placed them at various locations along the road connecting the barn with his house. Each bale j has a s…
[题意]给定n头牛,k个特色,给出每头牛拥有哪些特色的二进制对应数字,[i,j]平衡当且仅当第i~j头牛的所有特色数量都相等,求最长区间长度. [算法]平衡树+数学转化 [题解]统计前缀和sum[i][j]表示前i头牛特色为j的数量,则区间i~j平衡需要满足: sum[j][1]-sum[i-1][1]=sum[j][2]-sum[i-1][2]=sum[j][3]-sum[i-1][3]=... 移项可得,只须 sum[j][1]-sum[j][2]=sum[i-1][1]-sum[i-1][…
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并查集======================================[HDU]1213   How Many Tables   基础并查集★1272   小希的迷宫   基础并查集★1325&&poj1308  Is It A Tree?   基础并查集★1856   More i…
Layout   Description Like everyone else, cows like to stand close to their friends when queuing for feed. FJ has N (2 <= N <= 1,000) cows numbered 1..N standing along a straight line waiting for feed. The cows are standing in the same order as they…