问题虫洞——A:Eddy Walker ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190722160400947.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzIzNzI0Mg==,size_16,color_FFFFFF,t_70)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 1009
#define INF 0x3f3f3f3f//将近ll类型最大数的一半,而且乘2不会爆ll
const ll mod = 1000000007;
ll inv(ll b){ return b == 1? 1: (mod-mod/b)*inv(mod%b)%mod;}//递推求乘法逆元
//ll (ll a, ll b)
//{
// ll ans = 1;
// while(b){
// if(b&1)
// ans = ans*a%mod;
// a = a*a%mod;
// b>>=1;
// }
// return ans;
//}
//int main()
//{
// ll ans = (n-1, mod-2);
//}
int main()
{
ll t, ans=1;
cin >> t;
while(t--){
ll n, m;
cin >> n >> m;
if(n == 1) ans = ans;
else {
if(m == 0) ans=0;
else ans = ans*inv(n-1)%mod;
}
cout << ans << '\n';
}
return 0;
}
问题虫洞——D:Kth Minimum Clique
题意:
给你一个有n个点我无向图邻接矩阵,给出每个点的权值,求第k小的完全子图(空集是最小的完全子图)
来来来,推荐一篇好看的博客:牛客网多校训练第二场D Kth Minimum Clique
(还有,师哥说我头文件恶心,恶心嘛?恶心嘛?不恶心啊。标准右对齐好嘛)
//#include<bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include<algorithm>
#include <map>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <cstring>
#include <string.h>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f//将近ll类型最大数的一半,而且乘2不会爆ll
const ll mod = 1000000007;
const int MAXN = 1e6 + 5;
int n, k;
ll val[105];
bitset<105>stu[105];
struct node
{
ll w;
int id;//记录当前团最后加入的点编号,当前团只加入最后加入点之后的点,达到去重的目的
bitset<105>clique;
friend bool operator<(const node&a, const node&b)
{
return a.w > b.w;
}
};
priority_queue<node>q;
int main()
{
cin >> n >> k;
for(int i=1; i<=n; ++i)
scanf("%lld", &val[i]);
int x;
for(int i=1 ; i<=n; ++i)
for(int j=1; j<=n; ++j)
{
scanf("%1d", &x);
stu[i][j] = x;
}
ll ans = -1;
node st;
st.id = 0;
st.w = 0;
q.push(st);
while(!q.empty())
{
node now = q.top();
q.pop();
k--;
if(!k)
{
ans = now.w;
break;
}
for(int i=now.id+1; i<=n; ++i)
{
if((now.clique&stu[i]) == now.clique)//说明点i与当前团中的点都相连
{
node next;
next.id = i;
next.clique = now.clique;
next.clique[i] = 1;
next.w = now.w + val[i];
q.push(next);
}
}
}
cout << ans << '\n';
return 0;
}
问题虫洞——F:Partition problem
(一个一个往外拉,往外拉,往外拉)
//#include<bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include<algorithm>
//#include <map>
//#include <set>
//#include <vector>
//#include <queue>
//#include <stack>
#include <stdlib.h>
#include <cstring>
#include <string.h>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f//将近ll类型最大数的一半,而且乘2不会爆ll
const ll mod = 1000000007;
const int MAXN = 1e6 + 5;
int D[30][30], p1[30], p2[30], n, a=0, b=0;
ll ans;
void dfs(int c, ll sum)
{
if(a+b == n) {ans = max(ans, sum); return;}
if(a<n/2)
{
ll ret = 0;
p1[a++] = c;
for(int i=0; i<b; ++i)
ret+=D[c][p2[i]];
dfs(c+1, sum+ret);
a--;
}
if(b < n/2)
{
ll ret = 0;
p2[b++] = c;
for(int i=0; i<a; ++i)
ret+=D[c][p1[i]];
dfs(c+1, sum+ret);
b--;
}
}
int main()
{
cin >> n;
n*=2;
for(int i=0; i<n; ++i)
for(int j=0; j<n; ++j)
scanf("%d", &D[i][j]);
dfs(0, 0);
cout << ans << '\n';
return 0;
}
问题虫洞——H:Second Large Rectangle ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190722164303349.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzIzNzI0Mg==,size_16,color_FFFFFF,t_70)
其实比较典型的是单调栈和悬线法,,,,
//#include<bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define MAXN 1009
#define INF 0x3f3f3f3f//将近ll类型最大数的一半,而且乘2不会爆ll
const ll mod = 1000000007;
int dp[MAXN*2][MAXN*2];
int sum=-1, ans=-1;
int main()
{
int n, m;
cin >> n >> m;
for(int i=1; i<=n; ++i)
for(int j=1; j<=m; ++j)
{
scanf("%1d", &dp[i][j]);
dp[i][j]+=dp[i-1][j]*dp[i][j];//向上的高度
}
for(int i=1; i<=n; ++i)
for(int j=1; j<=m; ++j)
{
int len = dp[i][j], dep=1;
while(len)
{
int cnt = len*dep;
if(cnt > ans){
sum = ans;
ans = cnt;
}
else if(cnt > sum)
sum = cnt;
len = min(len, dp[i][j-dep]);
dep++;
}
}
printf("%d\n", sum == -1? 0: sum);
return 0;
}