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

提交超级多次都WA后来把队列长度改成两百万就过了也不知道为什么 附代码

Posted by 799301180liyi at 2014-05-24 18:51:23 on Problem 3278
#include<iostream>
using namespace std;
struct{
	long point,t;
}line[200000];
bool bo[100100]={0};
long n,k,front,rear,mmin=10000000;
void push(long p,long t){
	if(p<=100100&&p>=0){
		if(!bo[p]&&t<mmin){
			bo[p]=true;
			line[rear].point=p;
			line[rear].t=t;
			//cout<<line[front].point<<' '<<p<<' '<<t<<endl;
			rear++;
		}
	}
}
int main()
{
	cin>>n>>k;
	front=0;rear=1;
	line[front].point=n;
	line[front].t=0;
	while(front!=rear){
		if(line[front].point==k){
			if(line[front].t<mmin)mmin=line[front].t;
		}
		else {
			push(line[front].point+1,line[front].t+1);
			push(line[front].point-1,line[front].t+1);
			push(line[front].point*2,line[front].t+1);
			bo[k]=false;
		}
		front++;
	}
	cout<<mmin;
}

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