bitset
1 #include<cstdio> 2 #include<algorithm> 3 #include<bitset> 4 #include<iostream> 5 using std::cin; 6 using std::cout; 7 using std::endl; 8 using std::bitset; 9 const int maxn = 1e6; 10 bitset<100000> bt[2]; 11 int a[maxn]; 12 int n; 13 int main(){ 14 cin >> n; 15 int m = 0; 16 for(int i = 1 ; i <= n ; i ++) { 17 cin >> a[i]; 18 m += a[i]; 19 } 20 for(int i = 1 ; i <= n ; i ++) { 21 bt[0] = bt[1] | (bt[1] << a[i]); 22 bt[1] = bt[0]; 23 bt[1][a[i]] = 1; 24 } 25 for(int i = 1 ; i <= m ; i ++) { 26 if(bt[1][i]) cout<<"exist : "<<i<<endl; 27 } 28 return 0; 29 }
子矩阵值最大
枚举竖行上下界,横行记录最大值和次大值
二分答案:枚举值,大于的为一,小于为0
找全是1的矩阵O(n^3)->bitset:数1的个数
logn*(n^2+(n^3)/32)