Robots

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 60    Accepted Submission(s): 13

Problem Description
QXJ has N robots on the plane, the i-th is at (xi,yi), numbereded 1 to N. Every robot is painted by one kind of color, numbered 1 to M.

Each robots can move K times. In one move,a robot at (x,y) can move to (x−1,y),(x,y+1),(x+1,y),(x,y−1).

After exactly K moves, she wants robots with same color to gather at the same postion and the robot on the i-th color gather at different postion with robots on (i-1)-th or (i+1)-th color.

Now she wants to know how many ways of moving these robots following to rules above.

Two ways are different if one of final postions of certain robot is different or there is at least one robot whose moving path is different.

 
Input
The first line is the number of test cases T(T≤10).

The first line of each case contains three integer N(1≤N≤200),M(1≤M≤20),K(1≤K≤500), indicating the number of robots ,the number of color and the number of steps robots can move.

The second line,contains M integer mi, indicating the number of robots with the i-th color.

The robots numbered [1,m1] are on the 1st color.The robots numbered [m1+1,m1+m2] are one the 2nd color, ans so on.

The next N line,each contains two integers xi,yi, indicating the postion of i-th robots..

(0≤|xi,yi|≤250).

 
Output
For each test case, output a single line "Case #x: y", where x is the case number, starting from 1. And y is the answer(module 109+7).
 
Sample Input
2
3 3 1
1 1 1
1 0
0 1
1 2
4 2 2
2 2
0 1
0 3
0 2
0 4
 
Sample Output
Case #1: 49
Case #2: 256
 
Author
UESTC
 
Source
 
题意:
有n个机器人,共有m种颜色,分别分布在一个二维坐标平面上,每次移动可以向四联通的地方移动,多个机器人可以重合。
问所有机器人分别恰好走K步后,每种颜色的机器人聚集在一起,并且相邻两种颜色不聚集在一起的方案数。
题解:
一定不要读错题,这题只要求编号相邻的颜色的机器人不能聚集在一个点,于是难度锐减。
可以首先令坐标变化,x‘=x+y,y'=x-y。
如此,当(x,y)向四联通方格发生变化时,及变化量为(+-1,0)(0,+-1)时,(x',y')的变化为(+-1,+-1)。
无论原坐标如何改变,新坐标的两维都会发生改变。
在考虑到每个新坐标唯一确定了原坐标,这就给我们一个很好的性质:
新坐标两维可以分开考虑x'、y'无论如何分开分别变化K次,我们都可以在原坐标上解释这种变化,并且移动步数也为K。
可以如此,先令Gx[i][S]为第i种颜色的机器人的X坐标聚集在S的方案数,Gy[i][S]同理。
然后在令f[i]为前i种颜色的机器人合法的聚集的方案数,那么利用容斥就可以计算这个东西。

  

 const int N = , M = , K = , SIZE = , MOD = 1e9 + ;
struct Point {
int x, y; inline void read() {
scanf("%d%d", &x, &y);
} inline void fix() {
int tx = x, ty = y;
x = tx + ty, y = tx - ty;
} inline int getCoor(int xy) const {
return xy ? y : x;
}
} arr[N];
int n, m, k, f[N];
int gather[][M][SIZE];
// coordinate -1500 ~ 1500
// real coordinate should be : i - 1501
// Size is SIZE
// 0 -> xcoordinate 1 -> y-coordinate
int dp[N], allAt[][SIZE]; inline int add(int x, int y) {
return (x + 0ll + MOD + 0ll + y) % MOD;
} inline int mul(int x, int y) {
return ((x * 1ll * y) % MOD + MOD) % MOD;
} int C[K][K];
inline void init() {
for(int i = ; i < K; ++i) C[i][] = ;
for(int i = ; i < K; ++i)
for(int j = ; j <= i; ++j)
C[i][j] = add(C[i - ][j - ], C[i - ][j]);
} inline int move(int st, int ed) {
int delta = abs(ed - st);
int freeMove = k - delta;
if(freeMove < || (freeMove & )) return ;
return C[k][freeMove / ];
} inline void solve() {
for(int i = ; i < m; ++i) f[i] += f[i - ];
for(int i = ; i < n; ++i) arr[i].fix(); for(int xy = ; xy < ; ++xy)
for(int i = ; i < m; ++i)
for(int w = ; w < SIZE; ++w) {
gather[xy][i][w] = ;
for(int j = i ? f[i - ] : ; j < f[i]; ++j)
gather[xy][i][w] = mul(gather[xy][i][w],
move(w - , arr[j].getCoor(xy)));
} for(int i = ; i < m; ++i) {
dp[i] = ; for(int xy = ; xy < ; ++xy)
for(int w = ; w < SIZE; ++w) allAt[xy][w] = ;
for(int j = i, coe = ; j >= ; --j, coe *= -) {
int allGather[] = {, };
for(int xy = ; xy < ; ++xy)
for(int w = ; w < SIZE; ++w) {
allAt[xy][w] = mul(allAt[xy][w], gather[xy][j][w]);
allGather[xy] = add(allGather[xy], allAt[xy][w]);
} int combine = mul(allGather[], allGather[]);
dp[i] = add(dp[i], mul(mul(coe, j ? dp[j - ] : ), combine));
}
} printf("%d\n", dp[m - ]);
} int main() {
freopen("f.in", "r", stdin);
init();
int testCase;
scanf("%d", &testCase);
for(int testIndex = ; testIndex <= testCase; ++testIndex) {
printf("Case #%d: ", testIndex);
scanf("%d%d%d", &n, &m, &k);
for(int i = ; i < m; ++i) scanf("%d", &f[i]);
for(int i = ; i < n; ++i) arr[i].read();
solve();
}
return ;
}
 
 
 
 

2016 ccpc 网络选拔赛 F. Robots的更多相关文章

  1. 2016 CCPC网络选拔赛 部分题解

    HDU 5832 - A water problem 题意:有两颗星球,一年的长度分别为37天和173天.问第n天时它们是否为新年的第一天. 思路:显然  n 同时被37和173整除时,两种历法都在新 ...

  2. HDU 5898 odd-even number(2016沈阳网络选拔赛 数位DP)

    定义DP[pos][pre][odd][even],pos代表当前数位,pre代表前一位的数值,odd代表到前一位连续的奇数个数,even代表到前一位连续偶数个数. odd和even肯定至少有一个为0 ...

  3. hdoj6708 2019 CCPC网络选拔赛 1007 Windows Of CCPC

    #include <cstdio> #include <iostream> #include <algorithm> using namespace std; ch ...

  4. hdoj6703 2019 CCPC网络选拔赛 1002 array

    题意 description You are given an array a1,a2,...,an(∀i∈[1,n],1≤ai≤n). Initially, each element of the ...

  5. 2016中国大学生程序设计竞赛 - 网络选拔赛 C. Magic boy Bi Luo with his excited tree

    Magic boy Bi Luo with his excited tree Problem Description Bi Luo is a magic boy, he also has a migi ...

  6. 2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛(8/11)

    $$2019中国大学生程序设计竞赛(CCPC)\ -\ 网络选拔赛$$ \(A.\hat{} \& \hat{}\) 签到,只把AB都有的位给异或掉 //#pragma comment(lin ...

  7. [BFS,A*,k短路径] 2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛 path (Problem - 6705)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=6705 path Time Limit: 2000/2000 MS (Java/Others)    Mem ...

  8. [贪心,dp] 2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛 Fishing Master (Problem - 6709)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=6709 Fishing Master Time Limit: 2000/1000 MS (Java/Othe ...

  9. 2016 CCPC 东北地区重现赛

    1. 2016 CCPC 东北地区重现赛 2.总结:弱渣,只做出01.03.05水题 08   HDU5929 Basic Data Structure    模拟,双端队列 1.题意:模拟一个栈的操 ...

随机推荐

  1. Yii2.0登录详解(下)

    在上一篇博文中,笔者讲述了yii2应用用户登陆的基本方法,但是这些方法到底是怎样实现登陆的呢?底层的原理到底是什么?在这篇博文笔者将从Yii的源码角度分析登陆的基本原理以及cookie自动登陆的原理, ...

  2. [NHibernate]增删改操作

    目录 写在前面 文档与系列文章 添加数据 删除数据 修改数据 添加修改数据 总结 写在前面 上篇文章介绍了nhibernate的基于面向对象的条件查询.对一个项目来说,增删改查是必不可少的,虽然实现方 ...

  3. VTK初学一,vtkDelaunay2D创建球冠曲面

    #ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRend ...

  4. Authcode()

    加密解密函数Authcode(): 1.  // 参数解释   2. // $string: 明文 或 密文   3. // $operation:DECODE表示解密,其它表示加密   4. //  ...

  5. godaddy域名使用DNSPod做DNS解析图文教程

    考虑到很多朋友看到英文就很头痛,在godaddy解析域名也不怎么方便,我们需要把在godaddy注册的域名,使用国内的DNS服务器,全部都是免费的哦. 首先打开www.dnspod.cn  用自己的常 ...

  6. T-SQL实用查询之分析数据库表的大小

    IF OBJECT_ID('tempdb..#TB_TEMP_SPACE') IS NOT NULL DROP TABLE #TB_TEMP_SPACE GO CREATE TABLE #TB_TEM ...

  7. LwIP移植和使用

    LwIP移植和使用 本手册基于lwip-1.4.x编写,本人没有移植过1.4.0之前的版本,更早的版本或许有差别.如果看官发现问题欢迎联系<QQ: 937431539  email: 93743 ...

  8. django 模板语法和三种返回方式

    模板 for循环 {% for athlete in athlete_list %} <li>{{ athlete.name }}</li> {% endfor %} if语句 ...

  9. bootstrap使用心得及css模块化的初步尝试

    第一次用bootstrap到实战项目,是一个企业门户站,可以说是强行拿bootstrap上来练手,感觉并不适合. 我是用的less编译bootstrap文件,直接改less变量.然后把不可重用的部分, ...

  10. [转]在MyEclipse中设置struts.xml自动提示功能

    导入标签:<%@ taglib uri="/struts-tags" prefix="s" %> 要想在MyEclipse中实现struts.xml ...