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. JS判断是不是本页面并且,给标签添加属性和属性值

    大多是在导航栏中用到的,在导航栏中在主页和在其他的网页点击导航栏中的主页是不同的,主要就是判断这个. 我是在ascs页面中写的. 下面先看标签: <a href="http://www ...

  2. 动软Model 模板 生成可空类型字段

    动软代码 生成可空类型 <#@ template language="c#" HostSpecific="True" #> <#@ outpu ...

  3. static用法总结

    C++的static有两种用法:面向过程程序设计中的static和面向对象程序设计中的static.前者应用于普通变量和函数,不涉及类:后者主要说明static在类中的作用. 一.面向过程设计中的st ...

  4. android LocalActivityManager说明

          类概述 Helper class for managing multiple running embedded activities in the same process. This c ...

  5. HIve体系结构,hive的安装和mysql的安装,以及hive的一些简单使用

    Hive体系结构: 是建立在hadoop之上的数据仓库基础架构. 和数据库相似,只不过数据库侧重于一些事务性的一些操作,比如修改,删除,查询,在数据库这块发生的比较多.数据仓库主要侧重于查询.对于相同 ...

  6. jq 写法

    <!doctype html> <html> <head> <meta charset="utf-8"> <script sr ...

  7. 轻松学习Linux之如何创建可执行脚本

    本文出自 "李晨光原创技术博客" 博客,谢绝转载!

  8. 第三百三十七天 how can I 坚持

    看了两集<太阳的后裔>,你眼中的你自己,真实的你自己,他眼中的你,你眼中的他,他眼中的他自己,真实的他自己.好乱. 何须让别人懂你,何须让自己懂自己,将就着一天天过吧. 睡觉.

  9. 【MySql】权限不足导致的无法连接到数据库以及权限的授予和撤销

    [环境参数] 1.Host OS:Win7 64bit 2.Host IP:192.168.10.1 3.VM: VMware 11.1.0 4.Client OS:CentOS 6 5.Client ...

  10. NSLog中的%@

    [NSLog中的%@] There is one additional substitution token available in Objective-C, %@, used to denote ...