Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

水题,为什么通过率这么低?

Posted by witstorm at 2018-05-11 22:30:53 on Problem 1059
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>

int die[1001];
int dn;

int pos[10];
int pn;

int chute[101];
int ladder[101];
int magic[101];
int get_magic[10];

int main()
{
	int temp;
	int a, b;
	dn = 0;
	while (scanf("%d", &temp) && temp)
	{
		die[dn++] = temp;
	}
	while (scanf("%d", &pn))
	{
		if (pn == 0)
		{
			break;
		}
		scanf("%d", &a);
		memset(chute, 0, sizeof(chute));
		memset(ladder, 0, sizeof(ladder));
		memset(magic, 0, sizeof(magic));
		memset(get_magic, 0, sizeof(get_magic));
		memset(pos, 0, sizeof(pos));

		scanf("%d", &b);
		if (a > b)
		{
			ladder[a] = b;
		}
		else
		{
			chute[a] = b;
		}
		while (scanf("%d", &a) && scanf("%d", &b) && a + b)
		{
			if (a > b)
			{
				ladder[a] = b;
			}
			else
			{
				chute[a] = b;
			}
		}
		while (scanf("%d", &temp) && temp)
		{
			if (temp < 0)
			{
				magic[-temp] = -1;
			}
			else
			{
				magic[temp] = 1;
			}
		}
		int pj = 0;
		for (int i = 0; i < dn; ++i)
		{
			while (get_magic[pj] != 0)
			{
				pj = (pj + 1) % pn;
			}
			//走步
			if (pos[pj] + die[i] == 100)
			{
				break;
			}
			else if (pos[pj] + die[i] < 100)
			{
				pos[pj] += die[i];
			}

			//解除魔法
			/*memset(get_magic, 0, sizeof(get_magic));*/
			bool fg = true;
			for (int j = 0; j < pn; ++j)
			{
				if (get_magic[j])
				{
					get_magic[j]--;
				}
			}
			for (int j = 0; j < pn; ++j)
			{
				if (get_magic[j] == 0)
				{
					fg = false;
					break;
				}
			}
			if (fg)
			{
				for (int j = 0; j < pn; ++j)
				{
					get_magic[j]--;
				}
			}

			//
			if (chute[pos[pj]])
			{
				pos[pj] = chute[pos[pj]];
			}
			else if (ladder[pos[pj]])
			{
				pos[pj] = ladder[pos[pj]];
			}



			//
			if (magic[pos[pj]] == 1)
			{
				continue;
			}
			else if (magic[pos[pj]] == -1)
			{
				get_magic[pj] = 2;
			}
			pj = (pj + 1) % pn;
			//
			
		}
		printf("%d\n", pj + 1);
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator