您当前的位置: 首页 > 

*DDL_GzmBlog

暂无认证

  • 1浏览

    0关注

    605博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

[Acwing] 第 17 场周赛

*DDL_GzmBlog 发布时间:2022-05-05 17:38:49 ,浏览量:1

B. 题意

给定一个 n × m n×m n×m 的方格矩阵。

每个方格要么是黑色,要么是白色。

请你计算,共有多少个非空方格集合满足:

  • 集合内的所有方格颜色都相同。
  • 集合内的任意两个方格都在同一行或同一列上
思路

因为数据范围很小

因此我们可以枚举每一行以及每一列,对于当前行统计出的 c n t cnt cnt

我们知道方案数就是

C c n t 1 + C c n t 2 . . + C c n t c n t C_{cnt}^1+C_{cnt}^2..+C_{cnt}^{cnt} Ccnt1​+Ccnt2​..+Ccntcnt​

又组合定理可知从 1.. c n t 1..cnt 1..cnt的组合我们可以化简为 2 ( c n t ) − 1 2^{(cnt)}-1 2(cnt)−1即可

code
// Problem: 方格集数量
// Contest: AcWing
// URL: https://www.acwing.com/problem/content/3975/
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
#define IOS  ios::sync_with_stdio(false);
#define CIT  cin.tie(0);
#define COT  cout.tie(0);

#define ll long long
#define x first
#define y second
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),x.end()
#define Fup(i,a,b) for(int i=a;i=b;i--)

typedef priority_queue  Pri_m;
typedef pair pii;
typedef vector VI;
map mp;
const int N = 60;


ll f[N][N];
int n,m;
char g[N][N];

void init(){
	for(int i = 0; i            
关注
打赏
1657615554
查看更多评论
0.0621s