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大学生程序设计竞赛训练》暑期课面向全球招生!

Re:哎,此题用LIST感觉还不是那么水呃,一次A过,STL太赞了。当然,O可没有随随便便写出了就,俺可是用心了的(附代码,供STL初学者参考)

Posted by liuhuanlong123 at 2020-04-01 17:33:55 on Problem 3125
In Reply To:哎,此题用LIST感觉还不是那么水呃,一次A过,STL太赞了。当然,O可没有随随便便写出了就,俺可是用心了的(附代码,供STL初学者参考) Posted by:Pzjay at 2009-09-11 11:34:52
> #include<iostream>
> #include<list>
> #include<algorithm>
> using namespace std;
> int main()
> {
> 	int m,n,k,i,j;
> 	int v,kk,tmp,sum,summ;
> 	list<int>pzj;
> 	list<int>::iterator ita;
> 	list<int>::iterator itb;
> 	scanf("%d",&m);
> 	while(m--)
> 	{
> 		sum=0;
> 		summ=0;
> 		pzj.clear();
> 		scanf("%d%d",&n,&k);
> 		for(i=0;i<n;i++)
> 		{
> 			scanf("%d",&v);
> 			pzj.push_back(v);
> 			if(i==k)
> 				kk=v;
> 		}
> 		bool cs=0;
> 		k++;
> 		while(find(pzj.begin(),pzj.end(),kk)!=pzj.end())
> 		{
> 			summ++;
> 			cs=0;
> 			tmp=pzj.front();
> 			for(i=9;i>tmp;i--)
> 				if(find(pzj.begin(),pzj.end(),i)!=pzj.end())
> 				{
> 					cs=1;
> 					break;
> 				}
> 				if(cs)
> 				{
> 					pzj.pop_front();
> 					pzj.push_back(tmp);
> 					if(summ==k)//防止数组中重复出现目标数字,要记录需要打印的数字的编号,并不时比较打印的是否是目标数字的标号
> 					{
> 						k=n-sum;
> 						summ=0;
> 					}
> 				}
> 				else
> 				{
> 					pzj.pop_front();
> 					sum++;
> 					if(summ==k)
> 						break;
> 				}
> 		}
> 		printf("%d\n",sum);
> 	}
> 	return false;
> }

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