URAL 1282 Game Tree
来源:互联网 发布:怎样自学c语言 编辑:程序博客网 时间:2024/05/17 01:38
#include <stdio.h>#define MAX_NODES 1001int numOfNodes;int resultOfLeaf[MAX_NODES];typedef struct Edge{int to;int next;}Edge;Edge EdgeArray[MAX_NODES];int EdgeNum;int head[MAX_NODES];int move(int node, int competitor){if (resultOfLeaf[node] != -2)return resultOfLeaf[node];int draw = 0;int i;for (i = head[node]; i != 0; i = EdgeArray[i].next){int result = move(EdgeArray[i].to, -competitor);if (result == competitor)return result;if (result == 0)draw = 1;}return draw ? 0 : -competitor;}int main(){scanf("%d", &numOfNodes);int to, from;char symbol[2];resultOfLeaf[1] = -2;for (to = 2; to <= numOfNodes; to++){resultOfLeaf[to] = -2;scanf("%s%d", symbol, &from);EdgeNum++;EdgeArray[EdgeNum].to = to;EdgeArray[EdgeNum].next = head[from];head[from] = EdgeNum;if (symbol[0] == 'L')scanf("%d", &resultOfLeaf[to]);}int result = move(1, 1);if (result == 1)printf("+1\n");else if (result == -1)printf("-1\n");elseprintf("0\n");return 0;}
0 0
- URAL 1282 Game Tree
- Ural 1282. Game Tree
- Ural Tree
- ural 1060 Flip Game
- URAL 1465 Pawn Game
- Ural 1180. Stone Game
- Ural 1180 Stone Game
- Ural 1060. Flip Game
- Ural 1465 Pawn Game
- Ural 1397. Points Game
- URAL 1976 Game Optimization
- URAL 1122 Game
- URAL 1180 Stone Game
- URAL 1022. Genealogical tree
- ural 1022 Genealogical Tree
- ural 1022. Genealogical Tree
- ural 1471 Tree题解
- Ural 1471. Tree
- hadoop1 eclipse插件编译
- Android中Scroller类的分析
- Eclipse搭建SSH(Struts2+Spring3+Hibernate3)框架项目教程
- 【turtlebot】陀螺仪的安装以及标定(iRobot Create 底盘+ADXRS610陀螺仪)
- Mysql常用命令详解;做参考文档使用
- URAL 1282 Game Tree
- codeforces 552 E. Vanya and Brackets
- Java语言基础之super关键字
- 鼠标放上去变另一个图片
- 浅析深究什么是中间件
- 1028. 人口普查(20)
- 欧洲行-前期准备
- 关于JSP页面的一些方法的使用
- The connection to adb is down, and a severe error has occured.You must restart adb and Eclipse.