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

请教一下高手,我错在哪了,我是菜鸟啊

Posted by moxiaomomo at 2010-03-29 13:13:00 on Problem 1068
#include<iostream>
#include<vector>
using namespace std;

int main()
{
	int p=0,n,m,i,j,k=1;
	vector<char> v2(10);
	vector<int> v1(10);

	cin>>m;

	while(m>0)
	{
		cin>>n;
 
		for(i=0;i<n;i++)
		{
			cin>>v2[i];
			v1[i]=v2[i]-48;
		}

        vector<int> v;
    
    	for(i=0,j=0;i<2*n;i++)
		{
		    if(i-j>=v1[j]&&j<n)
			{	
			   v.push_back(1);
			   j++;
			}
	    	else 
			{v.push_back(0);}
			cout<<v[i]<<" ";
		}
        cout<<endl;

	
	    for(i=0;i<2*n;i++)
		{
		    if(v[i]==1)
			{
			    for(j=i-1;j>=0;j--)
				{
				    if(v[j]==0){cout<<k<<" ";k=1;v[j]=2;break;}
				    else if(v[j]==2)k++;
				}
			}
		}
		cout<<endl;
		m--;
	}
	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