ZOJ 2975Kinds of Fuwas(暴力)
来源:互联网 发布:淘宝同一家店邮费 编辑:程序博客网 时间:2024/05/17 22:12
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2975
给出n*m的矩阵,要求算出四个角类型相同的小矩形的数目
使用暴力枚举任意两列,然后枚举每一行,统计每行的两列相同的个数,然后使用组合数求解,时间复杂度250^3.
#include<iostream>#include<cstdio>#include<set>#include<string>#include<string.h>#include<cstring>#include<vector>#include<map>#include<queue>#include<stack>#include<cctype>#include<algorithm>#include<sstream>#define mt(a) memset(a,0,sizeof a)#define fl(a,b,c) fill(a,b,c)#define inf 1000000000+7using namespace std;typedef long long ll;char graph[300][300];ll g[5];int main(){ int T; cin >> T; while (T--) { int n, m;; ll ans = 0; memset(graph, 0, sizeof graph); memset(g, 0, sizeof g); scanf("%d %d", &n, &m); for (int i = 0; i < n; i++) scanf("%s", graph[i]); for (int i = 0; i < m; i++) { for (int j = i + 1; j < m; j++) { memset(g, 0, sizeof g); for (int k = 0; k < n; k++) { if (graph[k][i] == graph[k][j]) { if (graph[k][i] == 'B')g[0]++; else if (graph[k][i] == 'J')g[1]++; else if (graph[k][i] == 'H')g[2]++; else if (graph[k][i] == 'Y')g[3]++; else if (graph[k][i] == 'N')g[4]++; } } for (int k = 0; k < 5; k++) { if(g[k])ans += ((g[k] * (g[k] - 1)) / 2); } } } printf("%lld\n", ans); } return 0;}
0 0
- ZOJ 2975Kinds of Fuwas(暴力)
- zoj 2975 Kinds of Fuwas(数学题)
- ZOJ - 2975 Kinds of Fuwas
- zoj 2975 Kinds of Fuwas
- zoj 2975 Kinds of Fuwas
- ZOJ - 2975 Kinds of Fuwas
- ZOJ 2975 Kinds of Fuwas
- zoj 2975 Kinds of Fuwas
- zoj 2975 Kinds of Fuwas
- ZOJ 2975 Kinds of Fuwas
- ZOJ 2975Kinds of Fuwas
- ZOJ 2975-K - Kinds of Fuwas-暴力+bitset
- ZOJ-2975-Kinds of Fuwas【5th浙江省赛】【暴力】
- Kinds of Fuwas(暴力+组合数学)
- zoj 2975 Kinds of Fuwas(超时题)
- 【简单数学】ZOJ 2975 Kinds of Fuwas
- ZOJ 2975 Kinds of Fuwas【思维】
- Kinds of Fuwas ——zoj 2975
- mysql5.5免安装版
- Database LeetCode Department Highest Salary
- apple用什么方式实现对一个对象的KVO
- okhttp感想
- java内存可见性
- ZOJ 2975Kinds of Fuwas(暴力)
- 这两天对OKR简单总结
- java web开发实现properties文件的读取与解析
- PHP之自定义错误
- Nginx1.8.1+Tomcat7.0负载均衡
- c# pdf生成图片文字水印类
- 【BZOJ 2149】 拆迁队
- attachment和inline的区别
- spring中的DispatcherServlet