cf#8VC Venture Cup 2016 - Final Round (Div. 2 Edition) -A. Orchestra暴力水题
2016-03-17 23:45
411 查看
http://codeforces.com/contest/635/problem/A
在一个r*c矩阵 有n个钻石
有多少个不同的子矩阵可以覆盖至少k个钻石。。。数据范围只有10。。。。直接暴力枚举。。
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;
const double pi=acos(-1.0);
double eps=0.000001;
int mp[15][15];
int sum[15][15];
int main()
{
int i,j,g,h,f;
int x,y,k;
int r,c,n;
cin>>r>>c>>n>>k;
for (i=1;i<=n;i++)
{
scanf("%d%d",&x,&y);
mp[x][y]=1;
}
for (i=1;i<=r;i++)
{
for (j=1;j<=c;j++)
{
sum[i][j]=sum[i-1][j]+mp[i][j];
}
}
int tmp[15];
int ans=0;
for (i=1;i<=r;i++)
{
for (j=i;j<=r;j++)
{
for (h=1;h<=c;h++)
tmp[h]=sum[j][h]-sum[i-1][h];
for (h=1;h<=c;h++)
{
for (g=h;g<=c;g++)
{
int sum=0;
for (f=h;f<=g;f++)
sum+=tmp[f];
if (sum>=k)
ans++;
}
}
}
}
printf("%d\n",ans);
return 0;
}
在一个r*c矩阵 有n个钻石
有多少个不同的子矩阵可以覆盖至少k个钻石。。。数据范围只有10。。。。直接暴力枚举。。
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;
const double pi=acos(-1.0);
double eps=0.000001;
int mp[15][15];
int sum[15][15];
int main()
{
int i,j,g,h,f;
int x,y,k;
int r,c,n;
cin>>r>>c>>n>>k;
for (i=1;i<=n;i++)
{
scanf("%d%d",&x,&y);
mp[x][y]=1;
}
for (i=1;i<=r;i++)
{
for (j=1;j<=c;j++)
{
sum[i][j]=sum[i-1][j]+mp[i][j];
}
}
int tmp[15];
int ans=0;
for (i=1;i<=r;i++)
{
for (j=i;j<=r;j++)
{
for (h=1;h<=c;h++)
tmp[h]=sum[j][h]-sum[i-1][h];
for (h=1;h<=c;h++)
{
for (g=h;g<=c;g++)
{
int sum=0;
for (f=h;f<=g;f++)
sum+=tmp[f];
if (sum>=k)
ans++;
}
}
}
}
printf("%d\n",ans);
return 0;
}
相关文章推荐
- 浏览器对象模型BOM
- Python中的numpy
- JS性能优化
- 第二天:tomcat体系结构和第一个Servlet
- Delphi结构中使用String时遇到的内存泄露问题(没有利用String的引用计数自动销毁字符串的功能)
- Python中的numpy
- Ubuntu解决virtualenv升级错误
- 设计模式之合成模式
- java SE基础知识初记(1)i
- jquery 现实多状态控件 (status & power(2,0)) = power(2,0)
- 技术社区
- Delphi主窗口任务栏菜单的问题(转发WM_SYSCOMMAND到Application)
- 当JAVA WEB服务器端有一个执行时间长的方法,应该如何处理?
- 个人博客
- IOS 获取地理位置信息并逆向解析
- JAVA 界面 - 记事本
- Python 文件目录操作
- 我的JS学习笔记-----函数
- [Getting and Cleaning data] swirl
- 快速排序(C/C++版)