随笔分类 -  水题

摘要:小Q的妈妈是一个出纳,经常需要做一些统计报表的工作。今天是妈妈的生日,小Q希望可以帮妈妈分担一些工作,作为她的生日礼物之一。经过仔细观察,小Q发现统计一张报表实际上是维护一个可能为负数的整数数列,并且进行一些查询操作。在最开始的时候,有一个长度为N的整数序列,并且有以下三种操作: INSERT i 阅读全文
posted @ 2018-05-31 21:43 walfy 阅读(128) 评论(0) 推荐(0)
摘要:题意:在一个4 4的方框内摆放了若干个相同的玩具,某人想将这些玩具重新摆放成为他心中理想的状态,规定移动时只能将玩具向上下左右四个方向移动,并且移动的位置不能有玩具,请你用最少的移动次数将初的玩具状态移动到某人心中的目标状态。 题解:状压状态,然后bfs时枚举每一位向四个方向转移即可,记得加vis, 阅读全文
posted @ 2018-05-28 20:41 walfy 阅读(128) 评论(0) 推荐(0)
摘要:题意:n个点m条边,找点集个数,点集满足有任意三个点成环,或者三个点互不相连 题解:暴力复杂度O(n^5/120*O(ok))==O(能过) //#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast,no- 阅读全文
posted @ 2018-05-17 20:19 walfy 阅读(257) 评论(0) 推荐(0)
摘要:https://csacademy.com/contest/archive/task/binary-differences n个数,只有0和1,求所有子区间价值不相同的有多少中,价值是0的个数-1的个数 解法:0的贡献是1,1的贡献是-1,求出贡献的前缀和为s[i],利用上一个区间[l,r]求出当前 阅读全文
posted @ 2018-03-07 15:17 walfy 阅读(156) 评论(0) 推荐(0)
摘要:二分比较容易想到 #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<ioma 阅读全文
posted @ 2017-08-14 08:52 walfy 阅读(214) 评论(0) 推荐(0)
摘要:#include #include #include #include #include #include using namespace std; #define MAXN 9999 #define MAXSIZE 10000 #define DLEN 4 class BigNum{ private: int a[MAXSIZE]; //可以控制大数的位数 int l... 阅读全文
posted @ 2017-07-23 20:39 walfy 阅读(163) 评论(0) 推荐(0)
摘要:超级坑的水题!!!想了两天没一点思路,看了题解第一段话就做出来了 刚开始一直在想找到通项就是例如an*10^n+...+a0*10^0-an-...-a0>=s,然后从这个里面找到规律,结果走进死胡同了 Let's prove that if x is really big, then x + 1  阅读全文
posted @ 2017-06-21 21:49 walfy 阅读(155) 评论(0) 推荐(0)
摘要:给n个圆要么包含,要么相分离,没有两个公共点,当成一棵树,把包含的面积大的放在上面 如图最上面的par记为-1,level记为0,当par 1||level==1时就加否则减, 就是第一,二层先加,第三层减,然后后面的一直交替就行了 #include<map> #include<set> #incl 阅读全文
posted @ 2017-06-18 23:29 walfy 阅读(130) 评论(0) 推荐(0)
摘要:这题挺有意思的,刚开始不会这交互题,模仿着做了一题就会了,蛮简单 的 这题我用2分,结果wa了,想了一下发现,1到1e9二分50次完全不够用啊,那就转换一下思维,先求出在10^n~10^(n+1)的n 然后进行二分,这样居然a了。。。 #include<map> #include<set> #inc 阅读全文
posted @ 2017-05-26 18:03 walfy 阅读(348) 评论(0) 推荐(0)
摘要:反正又是一个半小时没做出来。。。 先排序,然后求和,第i个和第j个,f(a)=a[j]-a[i]=a[i]*(2^(j-i-1))因为从j到i之间有j-i-1个数(存在或者不存在有两种情况) 又有a[i+k]-a[i]=a[n]+a[n-1]+...+a[n-k]-a[k+1]-...-a[1] # 阅读全文
posted @ 2017-05-26 17:09 walfy 阅读(244) 评论(0) 推荐(0)
摘要:The SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how many quadruplet (a, b, c, d ) ∈ A x B x C x D 阅读全文
posted @ 2017-04-24 15:30 walfy 阅读(666) 评论(0) 推荐(1)
摘要:D. Mike and distribution time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has always 阅读全文
posted @ 2017-04-22 17:51 walfy 阅读(326) 评论(0) 推荐(0)
摘要:D. k-Interesting Pairs Of Integers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output D. k- 阅读全文
posted @ 2017-03-24 14:22 walfy 阅读(410) 评论(0) 推荐(0)