Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
提交超级多次都WA后来把队列长度改成两百万就过了也不知道为什么 附代码#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator