POJ 1885 Uncompress G++ 输入巧妙 list使用 字符串s=s+c会超时 背

#include <iostream>
#include <cstdio>
#include <string>
#include <list>
using namespace std;
//英语    抄博友程序      输入巧妙     list使用      字符串s=s+c会超时        背
int main()
{
	//freopen("1885.txt","r",stdin);
	string s;
	list<string> table;
	list<string>::iterator it;
	char c;
	while((c=getchar())!=-1)s+=c;//抄博友程序    巧妙     s=s+c会超时 
	int pos=s.find_last_of("0");//抄博友程序   数字中可能出现0   巧妙 
	s.erase(pos,s.size());
	for(int i=0; i<s.size(); i++)
	{
		if('0'<=s[i] && s[i]<='9')
		{
			int num=0;
			while('0'<=s[i] && s[i]<='9')
			{
				num=num*10+s[i]-'0';
				i++;
			}
			i--;//抄博友程序 
			int pos=0;
			it=table.begin();
			while(++pos!=num)//抄博友程序 
			{
				it++; 
			}
			string temp=*it;
			cout<<temp;
			table.erase(it);//抄博友程序 
			table.push_front(temp); 
		}else if(('a'<=s[i] && s[i]<='z') ||('A'<=s[i] && s[i]<='Z'))
		{
			string temp;
			while(('a'<=s[i] && s[i]<='z') ||('A'<=s[i] && s[i]<='Z'))
			{
				temp+=s[i++];//temp=temp+s[i++]超时 
			}
			i--;
			table.push_front(temp);
			cout<<temp;
		}else
		{
			cout<<s[i];
		}
	} 
	return 0;
}  

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值