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. 10月28日PHP基础知识测试题

    本试题共40道选择题,10道判断题,考试时间1个半小时 一:选择题(单项选择,每题2分): 1. LAMP具体结构不包含下面哪种(A) A:Windows系统 B:Apache服务器 C:MySQL数 ...

  2. centos6.5升级python为2.7

    今天线上服务器全部升级python环境为python-2.7.6的环境,我采用的方法是ansible+shell,代码如下,友提,Python-2.7.6.tgz.setuptools-14.3.1. ...

  3. ThinkPHP真正疑难问题笔记

    如何选择线程安全版本还是非线程安全版本: http://www.cnblogs.com/Alight/p/3389113.html(看webserver处理请求时, 使用的是多线程的方式还是 多进程的 ...

  4. vijos1531 食物链

    背景 安徽省芜湖市第二十七中学测试题 NOI 2001 食物链(eat) Description:OfficialData:OfficialProgram:JackDavid127 描述 动物王国中有 ...

  5. JSP入门

    JSP简介 所谓JSP就是在网页文件中嵌入Java代码或JSP定义的一些标记.JSP是建立在Servlet上的,在执行时JSP容器会先将JSP文件转换成Servlet文件以及class 文件,然后再执 ...

  6. HMac基本介绍

    基本介绍 HMAC(散列消息身份验证码: Hashed Message Authentication Code) 它不是散列函数,而是采用散列函数(MD5 or 或SHA)与共享密钥一起使用的消息身份 ...

  7. jenkins自动化构建iOS应用配置过程中遇到的问题

    最近配置jenkins来自动构建iOS应用,期间遇上不少问题.在这里分享给大家,也给自己留个底,方便下次解决问题. 首先说明下基本情况,我们因为部署jenkins的机器不是Mac,所以不能安装Xcod ...

  8. 获取url传参

    function urlparameterforkey(name) { //读取html 数据 ); //待处理的字符串 var patt = new RegExp(name); //要查找的字符串 ...

  9. Windows7 + Ubuntu双系统安装过程记录

    本文为在已安装Windows7系统的前提下安装Ubuntu Kylin 14.10系统的过程以及期间出现的各种问题的记录. Ubuntu系统下载 Ubuntu Kylin中文官方网站:http://w ...

  10. windows系统和ubuntu虚拟机之间文件共享——samba

    参考:http://www.cnblogs.com/phinecos/archive/2009/06/06/1497717.html 一. samba的安装: sudo apt-get insall  ...