250pt:
暴力枚举所有的可能的情况就好了,求面积的时候我是用梯形的面积减去两个三角形的面积。。
550pt:
题意:给你一个蜂窝形状的特殊图形,有一些格子已经被占据了,问你将剩下的格子用1*2的砖块尽可能的铺满的总方案数,见下图。


此题想了半天,隐约感觉可以dp,但是无从D起,,,膜拜了下rng_58的超短代码(大部分人选择dfs转移),但是rng_58将图转换成网格后巧妙的使用逐格递推的方法,代码超短,简直就是高端洋气上档次啊,好想又好写,这种题我以前都是dfs写转移的,要,b半天才能写出来。。
 #include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
class HexagonalBattlefield{
public :
int countArrangements(vector <int> X, vector <int> Y, int N) ;
};
int g[250][250];
long long dp[2][1<<15];
const int mod = 2000000011;
void Add(long long &x,int y)
{
x += y;
if(x >= mod) x -= mod;
}
int dx[] = {1,0,-1,0,1,-1};
int dy[] = {0,1,0,-1,1,-1};
vector<pair<int,int> > p;
int HexagonalBattlefield::countArrangements(vector <int> X, vector <int> Y, int N)
{
N --;
for(int i = -N; i <= N; i++) {
for(int j = -N; j <= N; j++) if(abs(i-j) <= N ){//ddddd
// puts("ddd");
int t = 0;
for(int k = 0; k < X.size(); k++) {
if(i == X[k] && j == Y[k]) {t=1;break;}
}
if(!t) p.push_back(make_pair(i,j));
}
}
// puts("dddd");
int m = p.size();
for(int i = 0; i < m; i++) {
int x = p[i].first , y = p[i].second;
for(int j = 0; j < 6; j++) {
int tx = x + dx[j];
int ty = y + dy[j];
for(int k = 0; k < m; k++) if(tx == p[k].first && ty == p[k].second) {
g[i][k] = true;
}
}
}
// printf("m=%d\n",m);
// puts("debug");
int cur = 0, nxt = 1;
dp[cur][0] = 1;
for(int i = 0; i < m; i++) {
// printf("i=%d\n",i);
memset(dp[nxt],0,sizeof(dp[nxt]));
for(int j = 0; j < (1<<15); j++) if(dp[cur][j]){
if(j&1) {Add(dp[nxt][j>>1] , dp[cur][j]); continue;}
for(int k = 1; k <= 15; k++) if(i+k < m && g[i][i+k] && !( j&(1<<k) ) ) {
int mask = ( j | (1 << k) )>> 1;
Add(dp[nxt][mask] , dp[cur][j]);
}
}
std::swap(cur,nxt);
}
return dp[cur][0];
}


												

SRM 449 div1 (practice)的更多相关文章

  1. Topcoder SRM 643 Div1 250<peter_pan>

    Topcoder SRM 643 Div1 250 Problem 给一个整数N,再给一个vector<long long>v; N可以表示成若干个素数的乘积,N=p0*p1*p2*... ...

  2. Topcoder Srm 726 Div1 Hard

    Topcoder Srm 726 Div1 Hard 解题思路: 问题可以看做一个二分图,左边一个点向右边一段区间连边,匹配了左边一个点就能获得对应的权值,最大化所得到的权值的和. 然后可以证明一个结 ...

  3. 图论 SRM 674 Div1 VampireTree 250

    Problem Statement      You are a genealogist specializing in family trees of vampires. Vampire famil ...

  4. TopCoder SRM 605 DIV1

    604的题解还没有写出来呢.先上605的. 代码去practice房间找. 说思路. A: 贪心,对于每个类型的正值求和,如果没有正值就取最大值,按着求出的值排序,枚举选多少个类型. B: 很明显是d ...

  5. SRM 583 DIV1

    A 裸最短路. class TravelOnMars { public: int minTimes(vector <int>, int, int); }; vector<int> ...

  6. SRM 590 DIV1

    转载请注明出处,谢谢viewmode=contents">http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlov ...

  7. Topcoder SRM 602 div1题解

    打卡- Easy(250pts): 题目大意:rating2200及以上和2200以下的颜色是不一样的(我就是属于那个颜色比较菜的),有个人初始rating为X,然后每一场比赛他的rating如果增加 ...

  8. 状态压缩DP SRM 667 Div1 OrderOfOperations 250

    Problem Statement      Cat Noku has just finished writing his first computer program. Noku's compute ...

  9. 数学 SRM 690 Div1 WolfCardGame 300

    Problem Statement      Wolf Sothe and Cat Snuke are playing a card game. The game is played with exa ...

随机推荐

  1. cJSON学习笔记

    1.JSON格式简述 JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.易于人阅读和编写,同时也易于机器解析和生成.它基于JavaScript(Standa ...

  2. dispatch_once单例初始化

    static GHCache *instance = nil; /** *  单例,静态初始化方法 * *  @return 返回一个单例 */ + (GHCache*)shareCache{ sta ...

  3. javascript对象事件绑定方法

    javascript对象事件绑定方法 今天在做对象事件绑定的过程中出现了一点异外情况,由于事件方法是由参数传过来的,需要将当前对象call过去,方便方法体里直接调用this 错误写法 obj.oncl ...

  4. xshell 上传 下载文件

    借助XShell,使用linux命令sz可以很方便的将服务器上的文件下载到本地,使用rz命令则是把本地文件上传到服务器. sz用法: 下载一个文件 sz filename 下载多个文件 sz file ...

  5. U盘安装RedHat 5.3

    转载自http://www.cnblogs.com/totozlj/archive/2012/06/03/2532757.html 1.下载rhel-5.3-server-i386-dvd.iso文件 ...

  6. java webservice的多种实现方法汇总

    一.基于EJB容器管理webservice :     1.首先建立一个Web services EndPoint: package cn.test.service.impl; import java ...

  7. Codeforces Educational Codeforces Round 15 E - Analysis of Pathes in Functional Graph

    E. Analysis of Pathes in Functional Graph time limit per test 2 seconds memory limit per test 512 me ...

  8. Mellanox vma

    1,Mellanox offical vma Installation guide personal reading summarize VMA是一个消息加速器messaging accelerato ...

  9. T-SQL运算符

    运算符 1.算术运算符 算术运算符 说明 + 加法 - 减法 * 乘法 / 除法 % 取模,两个整数相除后的余数 2.位运算符 位运算符 说明 &(与.and) 按位逻辑与运算 |(或.OR) ...

  10. systemd详解

    CentOS 7 使用systemd替换了SysV.Systemd目的是要取代Unix时代以来一直在使用的init系统,兼容SysV和LSB的启动脚本,而且够在进程启动过程中更有效地引导加载服务. s ...