题目 题意: 给你n(最大36)个数,让你从这n个数里面找出来一些数,使这些数的和等于s(题目输入),用到的数输出1,没有用到的数输出0 例如:3  4 2 3 4 输出:0 0 1 题解: 认真想一下这一道题,首先看到n不是多大就想用dfs(超时),又在dfs的基础上记忆化(超时),大概是我记忆化不完全.又想用01背包,打出来代码后发现s就是体积,但是s的范围太大了,数组存不下 T_T 看题解发现用一个叫 折半枚举(就是一种思想) 和 二进制枚举 的东西 折半枚举:比如有时集合过大无法全部搜索…
题意:给出由01组成的矩阵,求求全是1的次大子矩阵. 思路: 单调栈 全是1的最大子矩阵的变形,不能直接把所有的面积存起来然后排序取第二大的,因为次大子矩阵可能在最大子矩阵里面,比如: 1 0 0 1 1 1 1 1 1 有篇博主的代码细节处理的很好,由于矩阵每行的长度一致,则不必重复在数组末尾标记0:然后由于j是从1,最开始如果push进0的话,有两个好处: 1.可以不受栈之前"残留"的元素m+1的影响 2.不用再判断栈是某为空来确定wid的值 Code #include <b…
layout: post title: 2019牛客暑期多校训练营(第五场)G - subsequeue 1 (一题我真的不会的题) author: "luowentaoaa" catalog: true tags: mathjax: true - ACM-ICPC 题意 给你两个由数字组成的字符串\(S\),\(T\) 长度为\(1e3\),问你S中有多少个子序列的值大于字符串T: 思路 首先在比赛的时候一眼确定是\(N^2\) 复杂度的DP,但是想了两三个小时却没想到怎么转移,各种…
题意:求Σfi^m%p. zoj上p是1e9+7,牛客是1e9:  对于这两个,分别有不同的做法. 前者利用公式,公式里面有sqrt(5),我们只需要二次剩余求即可.     后者mod=1e9,5才mod下没有二次剩余,所以不能这么做了.可以分解mod,然后利用循环节搞. zoj: #include <bits/stdc++.h> using namespace std; typedef long long LL; ; ; LL fac[N],A[N],B[N]; void Init() {…
链接:https://ac.nowcoder.com/acm/contest/889/D来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 Amy asks Mr. B  problem D. Please help Mr. B to solve the following problem. Amy wants to crack Merkle–Hellman knapsack…
链接:https://ac.nowcoder.com/acm/contest/881/A来源:牛客网 题目描述 Two arrays u and v each with m distinct elements are called equivalent if and only if RMQ(u,l,r)=RMQ(v,l,r)RMQ(u,l,r)=RMQ(v,l,r) for all 1≤l≤r≤m1≤l≤r≤mwhere RMQ(w,l,r)RMQ(w,l,r) denotes the inde…
链接:https://ac.nowcoder.com/acm/contest/881/B 来源:牛客网 Integration 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 524288K,其他语言1048576K 64bit IO Format: %lld 题目描述 Bobo knows that ∫ ∞ 0 1 1 x 2 d x = π 2 . ∫0∞11+x2 dx=π2. Given n distinct positive integers a 1 , a 2 , -…
链接:https://ac.nowcoder.com/acm/contest/881/A 来源:牛客网 Equivalent Prefixes 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 524288K,其他语言1048576K 64bit IO Format: %lld 题目描述 Two arrays u and v each with m distinct elements are called equivalent if and only if R M Q ( u ,…
链接:https://ac.nowcoder.com/acm/contest/882/F来源:牛客网 Given 2N people, you need to assign each of them into either red team or white team such that each team consists of exactly N people and the total competitive value is maximized. Total competitive va…
链接:https://ac.nowcoder.com/acm/contest/888/E来源:牛客网 Gromah and LZR have entered the fifth level. Unlike the first four levels, they should do some moves in this level. There are nn_{}n​ vertices and mm_{}m​ bidirectional roads in this level, each road…