HDU 6336 Matrix from Arrays】的更多相关文章

Problem E. Matrix from Arrays Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 501    Accepted Submission(s): 210 Problem Description Kazari has an array $A$ length of $L$, she plans to generat…
遇事不决先打表. 然后会发现(个屁)大的矩形是由一个2L*2L的矩形重复出现组成的然后我们就可以这个矩形分成四个点到(0, 0)点的矩形,这样问题就变成了求四个到顶点(0, 0)的矩形的面积,然后就先去求这里面完整的块数,然后去找边缘的有一边是完整的块,然后找最右下角的没有完整的块的面积,然后加起来就可了 #include<map> #include<set> #include<ctime> #include<cmath> #include<stack…
6336.Problem E. Matrix from Arrays 不想解释了,直接官方题解: 队友写了博客,我是水的他的代码 ------>HDU 6336 子矩阵求和 至于为什么是4倍的,因为这个矩阵是左上半边有数,所以开4倍才能保证求的矩阵区域里面有数,就是图上的红色阴影部分,蓝色为待求解矩阵. 其他的就是容斥原理用一下,其他的就没什么了. 代码: //1005-6336-矩阵求和-二维前缀和+容斥-预处理O(1)查询输出 #include<iostream> #include&…
Problem E. Matrix from Arrays Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Submission(s): Problem Description Kazari has an array A length of L, she plans to generate an infinite matrix M using A. The p…
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6336 Problem E. Matrix from Arrays Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1711    Accepted Submission(s): 794 Problem Description Kazari…
Problem E. Matrix from Arrays Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 474    Accepted Submission(s): 202 Problem Description Kazari has an array A length of L, she plans to generate an…
Problem E. Matrix from Arrays Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1162    Accepted Submission(s): 522 Problem Description Kazari has an array A length of L, she plans to generate a…
HDU 4920 Matrix multiplication 题目链接 题意:给定两个矩阵,求这两个矩阵相乘mod 3 思路:没什么好的想法,就把0的位置不考虑.结果就过了.然后看了官方题解,上面是用了bitset这个东西,能够用来存大的二进制数,那么对于行列相乘.事实上就几种情况,遇到0都是0了,1 1得1,2 1,1 2得2,2 2得1.所以仅仅要存下行列1和2存不存在分别表示的二进制数.然后取且bitcount一下的个数,就能够计算出对应的数值了 代码: 暴力: #include <cst…
HDU 2686 Matrix 题目链接 3376 Matrix Again 题目链接 题意:这两题是一样的,仅仅是数据范围不一样,都是一个矩阵,从左上角走到右下角在从右下角走到左上角能得到最大价值 思路:拆点.建图,然后跑费用流就可以,只是HDU3376这题,极限情况是300W条边,然后卡时间过了2333 代码: #include <cstdio> #include <cstring> #include <vector> #include <queue>…
Problem E. Matrix from Arrays Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1384    Accepted Submission(s): 630 Problem Description Kazari has an array A length of L, she plans to generate a…
题意: for (int i = 0; ; ++i) { for (int j = 0; j <= i; ++j) { M[j][i - j] = A[cursor]; cursor = (cursor + 1) % L; }} 给定序列A[1..L],二维数组M的规律由以上代码给出.Q个查询,每次给x0,y0,x1,y1 (0≤x0≤x1≤1e8,0≤y0≤y1≤1e8)四个数,求以(x0,y0)和(x1,y1)两个点为端点的矩形中数的和. 分析:根据推导可得,M[i][j] = M[i+2L…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 找个规律会发现 M[i][j] = M[i-2*L][j] = M[i][j-2*L] 先预处理出来(1,1)-(2L,2L)这个矩阵以及他的二维前缀和 那么对于要求的(x0,y0)-(x1,y1)这个矩阵. 可以用若干个(1,1)-(x,y)这样的前缀矩阵通过加加减减算出来. 对于(1,1)-(x,y)这样的矩阵. 显然是由若干个(1,1)-(2L,2L)矩阵合并而成的(x/L)*(y/L)个. 多余的部分(下边,右下角以及右…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2686 Yifenfei very like play a number game in the n*n Matrix. A positive integer number is put in each area of the Matrix.Every time yifenfei should to do is that choose a detour which frome the top left…
matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5569 Description Given a matrix with n rows and m columns ( n+m is an odd number ), at first , you begin with the number at top-left corner (1,1) and you wa…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2119 Matrix Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2205    Accepted Submission(s): 975 Problem Description Give you a matrix(only contains…
Matrix 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5671 Description There is a matrix M that has n rows and m columns (1≤n≤1000,1≤m≤1000).Then we perform q(1≤q≤100,000) operations: 1 x y: Swap row x and row y (1≤x,y≤n); 2 x y: Swap column x and c…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6336 题目: 题意:给你一个l个元素的数组a,用题目中的程序构造一个新的矩阵,询问q次,问以(x1,y1)为左上角,(x2,y2)为右下角的矩阵内的元素之和(原点在左上角). 思路:我们通过打表可以发现这个大矩阵都是以左上角2l*2l的小矩阵M循环出现的,所以对于每次查询我们只需统计他要查询的矩阵包含多少个完整的M,对于那些不构成完整的行列和,我们首先用前缀和统计出来,最后加起来即可.我的方法用下图…
原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=5015 解题思路:一看到题目,感觉是杨辉三角形,然后用组合数学做,不过没想出来怎么做,后来看数据+递推思想,感觉可能是矩阵快速幂,可惜一直不知道a*10+3的 +3怎么处理,果然还是图样图森破啊!如果矩阵能搞出来的话,后面的就简单了,真可惜一直到比赛结束也没想出来,看来这种矩阵的题目做的太少了,真后悔线性代数没有认真学.. 今天晚上又想了一会,完全可以把+3那个放到新的一阶矩阵上,值始终等于3,那么对…
Matrix Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3095    Accepted Submission(s): 1428 Problem Description Give you a matrix(only contains 0 or 1),every time you can select a row or a colu…
Matrix Swapping II Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1430    Accepted Submission(s): 950 Problem Description Given an N * M matrix with each entry equal to 0 or 1. We can find som…
Matrix multiplication Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description Given two matrices A and B of size n×n, find the product of them. bobo hates big integers. So you are only asked to find t…
要注意取出来的时候 先取出q的是后面那个矩阵 后取出p的是前面的矩阵 所以是判断 p.a == q.b #include <iostream> #include <stack> #include <cstring> #include <cstdio> using namespace std; struct Matrix{ int a,b; Matrix(,):a(aa),b(bb){} }m[]; stack<Matrix>s; int main…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4920 解题报告:求两个800*800的矩阵的乘法. 参考这篇论文:http://wenku.baidu.com/link?url=261XeEzH-AZkFGPiN63t1nnojoQF50yiuMoviHroGjVXjjRlxFcvWLcws0jgQcmZo4oA9BJcjnPxVreWRu-XXa9zb6r5gUUTxmBXn_qWSsu&qq-pf-to=pcqq.group 我看过了,只是简…
Matrix multiplication Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1775    Accepted Submission(s): 796 Problem Description Given two matrices A and B of size n×n, find the product of them.…
Matrix Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 502    Accepted Submission(s): 215 Problem Description There is a matrix M that has n rows and m columns (1≤n≤1000,1≤m≤1000).Then we perf…
Problem Description C++编程考试使用的实时提交系统,具有即时获得成绩排名的特点.它的功能是怎么实现的呢? 我们做好了题目的解答,提交之后,要么"AC",要么错误,不管怎样错法,总是给你记上一笔,表明你曾经有过一次错误提交,因而当你一旦提交该题"AC"后,就要与你算一算帐了,总共该题错误提交了几回.虽然你在题数上,大步地跃上了一个台阶,但是在耗时上要摊上你共花去的时间.特别是,曾经有过的错误提交,每次都要摊上一定的单位时间分.这样一来,你在做出的…
Problem Description Given a matrix with n rows and m columns ( n+m ,) and you want to go to the number at bottom-right corner (n,m). And you must go right or go down every steps. Let the numbers you go through become an array a1,a2,...,a2k. The cost…
Problem Description Given an N * M matrix with each entry equal to 0 or 1. We can find some rectangles in the matrix whose entries are all 1, and we define the maximum area of such rectangle as this matrix's goodness. We can swap any two columns any…
Matrix multiplication                                                                           Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description Given two matrices A and B of size n×n, find the…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2686 思路:多线程dp,参考51Nod 1084:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1084 注:这道题用滚动数组优化反而WA,压到三维即可 代码: #include <bits/stdc++.h> using namespace std; ][],dp[][][]; int main() { int n;…