Codeforces 69D. Dot 博弈 dp
来源:互联网 发布:软件安全检测 编辑:程序博客网 时间:2024/06/05 20:56
This game is over, because except for a finite number (2) of reflections about the line y = x,the coordinates are changed to non-negative integer (and at least one coordinate is changed to a positive number).
Algorithm for solving this problem is DFS / BFS (states) where the state is a pair of coordinates, and two logical variables, which denote if the 1 (2) player had reflected a point about the line y = x.
Total number of states is obtained by S <= 4D^2 (pairs of coordinates) * 4 (Boolean variables).
Processing of one state takes O (N) actions (do not forget to try to reflect the point about the line y = x, if the player had not made it earlier in the game). Thereby, we have the overall asymptotic O (ND^2), which works on C + + in less than 200ms.
------------------------------------#include <iostream>#include <cstring>using namespace std;int n,d;int vx[30],vy[30];int f[1111][1111];int dfs(int x,int y){ int bx,by; bx=x+500; by=y+500; if (f[bx][by]!=-1) return f[bx][by]; if (x*x+y*y>=d*d) return 1; for (int i=1;i<=n;i++) { if (!dfs(x+vx[i],y+vy[i])) return f[bx][by]=1; } return f[bx][by]=0;}int main(){ int x,y; memset(f,-1,sizeof(f)); cin>>x>>y>>n>>d; for (int i=1;i<=n;i++) { cin>>vx[i]>>vy[i]; } if (dfs(x,y)) { cout<<"Anton"<<endl; } else { cout<<"Dasha"<<endl; } return 0;}
- Codeforces 69D. Dot 博弈 dp
- Codeforces 69D Dot (博弈)
- CodeForces 69D Dot (博弈+记忆化)
- CodeForces 69D Dot
- Codeforces 69D Dot(DFS)
- coderforce 69D.Dot
- codeforces 455B(博弈+dp)
- codeforces 148D Bag of mice (概率DP)【博弈模板】
- 【DP】CodeForces 148D
- Codeforces 221D(dp)
- Codeforces 572D,DP
- codeforces 9D DP
- codeforces 519D dp
- Codeforces 358D【DP】
- codeforces 474D DP
- Codeforces 830D [DP]
- Vasya and Chess - CodeForces 493 D 博弈
- codeforces 493D Vasya and Chess(博弈?)
- C-MINUS扫描程序 DFA图
- java面试题经典20例【第三季_常瑞鹏】
- 安卓JNI
- STM32 SPI总线
- 关于24点游戏的编程思路与基本算法
- Codeforces 69D. Dot 博弈 dp
- jqGrid 实现这种select - 同一列的不同行的select 的option 不同
- 快速排序
- enum和struct何union
- Android 4.0.3 源码结构分析
- source insight 3.5 遇到的奇怪问题(部分解决)
- 51单片机程序存储器扩展
- 编译android源码遇到错误处理
- etmvc中集成spring使用druid连接池