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. 《Python核心编程》18.多线程编程(二)

    18.1没有线程支持 #!/usr/bin/env python # -*- coding:utf-8 -*- from time import sleep, ctime def loop0(): p ...

  2. 【转】HTML5的小知识点小集合

    html5的小知识点小集合 html5知识   1.  Doctype作用?标准模式与兼容模式各有什么区别? (1).<!DOCTYPE>声明位于位于HTML文档中的第一行,处于<h ...

  3. 学习MySQL之单表操作(二)

    ##单表操作 ##创建表 CREATE TABLE t_employee( empno ), ename ), job ), MGR ), Hiredate DATE DEFAULT '0000-00 ...

  4. QString 和std::string互转

    std::string cstr; QString qstring; //****从std::string 到QString qstring = QString(QString::fromLocal8 ...

  5. css3的基本样式

    一.css3字体(@font-face) 二.css3动画 三.css3多列 四.CSS3 outline-offset 属性 五.CSS3 resize 属性

  6. 微信公众平台推出"微信保护"提升微信账号安全 附微信保护开启教程

    前两天小美女的微信公众平台要群发消息时提示需要绑定手机才能操作,当时还以为是动态ip的问题,今天微信公众平台安全中心就说升级了,原来那时已经在公测了.微信公众平台推出"微信保护", ...

  7. 数位dp模板

    #include <bits/stdc++.h> typedef long long LL; const int MOD = (int)1e9 + 7; LL L,R,G,T; int d ...

  8. Alpha版本十天冲刺——Day 5

    站立式会议 会前小侃:今天是双11,也是恰逢组内秋鑫同学生日,本组同学祝他双11生日快乐.天气好冷,注意保暖. 会议总结 队员 今天完成 遇到的问题 明天要做 感想 鲍亮 json数据解析学习,完成注 ...

  9. serialize存入数组

    原代码 def get_type type_list = "" if categories.include?"movie" type_list += " ...

  10. SQL,Linq,Lambda之间的转换练习

    1.查询Student表中的所有记录的Sname.Ssex和Class列. SQL:select sname,ssex,class from Students linq:from s in Stude ...