2013
12-09

# XYZZY

It has recently been discovered how to run open-source software on the Y-Crate gaming device. A number of enterprising designers have developed Advent-style games for deployment on the Y-Crate. Your job is to test a number of these designs to see which are winnable.
Each game consists of a set of up to 100 rooms. One of the rooms is the start and one of the rooms is the finish. Each room has an energy value between -100 and +100. One-way doorways interconnect pairs of rooms.The player begins in the start room with 100 energy points. She may pass through any doorway that connects the room she is in to another room, thus entering the other room. The energy value of this room is added to the player’s energy. This process continues until she wins by entering the finish room or dies by running out of energy (or quits in frustration). During her adventure the player may enter the same room several times, receiving its energy each time.

The input consists of several test cases. Each test case begins with n, the number of rooms. The rooms are numbered from 1 (the start room) to n (the finish room). Input for the n rooms follows. The input for each room consists of one or more lines containing:the energy value for room i
the number of doorways leaving room i
a list of the rooms that are reachable by the doorways leaving room i
The start and finish rooms will always have enery level 0. A line containing -1 follows the last test case.

In one line for each case, output “winnable” if it is possible for the player to win, otherwise output “hopeless”.

5
0 1 2
-60 1 3
-60 1 4
20 1 5
0 0
5
0 1 2
20 1 3
-60 1 4
-60 1 5
0 0
5
0 1 2
21 1 3
-60 1 4
-60 1 5
0 0
5
0 1 2
20 2 1 3
-60 1 4
-60 1 5
0 0
-1

hopeless
hopeless
winnable
winnable

#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define INF 1000000000

int dis[120],va[120],mark[120];
int main()
{
int n,num,i,j,k,e;
while(scanf("%d",&n)!=EOF)
{
if(n==-1)
break;
for(i=1;i<=n;i++)
{
dis[i]=0;
mark[i]=0;
}
dis[1]=100;
for(i=1;i<=n;i++)
{
scanf("%d%d",&va[i],&num);
while(num--)
{
scanf("%d",&e);
}
}
mark[1]=1;
int flag=1;
for(i=1;i<n;i++)
{
flag=0;
for(j=1;j<=n;j++)
{
if(!mark[j])
continue;
for(k=0;k<size;k++)
{
if(dis[j]+va[e]>dis[e])
{
flag=1;
dis[e]=dis[j]+va[e];
mark[e]=1;
}
}
}
if(!flag) break;
}
while(1)
{
flag=0;
for(j=1;j<=n;j++)
{
if(!mark[j])
continue;
for(k=0;k<size;k++)
{
if(dis[j]+va[e]>dis[e])
{
flag=1;
dis[e]=INF;
mark[e]=1;
va[e]=-100;
}
}
}
if(!flag)
break;
}
if(dis[n]>0)
printf("winnable\n");
else
printf("hopeless\n");
}
return 0;
}

1. 你没仔细看我的评论吗？月球是颗死星，哪来的“地质裂痕”？“固态水”现在也仅是根据观测到的现象推测的结果，并未找到实证~

2. bottes vernies blanches

I appreciate the efforts you men and women place in to share blogs on such sort of matters, it was certainly useful. Keep Posting!