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
欢迎参加IJCAI 2020麻将智能体竞赛,大奖等你拿!Welcome to IJCAI 2020 Mahjong AI competition with amazing prizes! | 北京大学《ACM/ICPC大学生程序设计竞赛训练》暑期课面向全球招生!

大牛帮忙看看哪里错了??

Posted by hdjtdxacm at 2009-03-21 10:24:38 on Problem 2828
#include<stdio.h>
struct st
{
	int pos,val;
}a[200010];
int b[200010],p[200010],c[1001],first[1001];
int main()
{
	int i,j,k,t,r,e,f,n,cnum;
	while(scanf("%d",&n)!=EOF)
	{
		if(n == 1)
		{
			scanf("%d%d",&e,&f);
			printf("%d\n",f);
			continue;
		}
		cnum = (n + 199)/200;
		for(i = 1;i < cnum ;i++)
		{
	    	c[i] = 200;
	    	first[i] = 1 + (i-1)*200;
		}
		if(n%200)
			c[cnum] = n%200;
		else
			c[cnum] = 200;
		first[cnum] = 1 + (i-1)*200;
    	for(i = 1;i <= n;i++)
    		p[i] = 0;
		for(i = 1;i <= n;i++)
    		scanf("%d%d",&a[i].pos,&a[i].val);
    	b[a[n].pos+1] = a[n].val;
		p[a[n].pos+1] = 1;
    	for(i = n-1;i >= 1;i--)
		{
			j = 1;
			while(a[i].pos + 1 > c[j])
			{
				a[i].pos -= c[j];
				j++;
			}
			t = 0;	r = j;	f = first[r] + 199;
			if(r == cnum)
				f = n;
			for(k = first[r];k <= f;k++)
			{
			   	if(p[k]==0)
			    	t++;
				if(t == a[i].pos + 1)
					break;
			}
			c[r]--;
			b[k] = a[i].val;
			p[k] = 1;
		}
		for(i = 1;i < n;i++)
			printf("%d ",b[i]);
		printf("%d\n",b[n]);
	}
	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