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 lgchenyu at 2007-11-26 02:05:53 on Problem 1068
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
    
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    char a[1000000];
    char dp[1000000];
    int t,sum,jishu;
    int n,m;
    int i,j;
    cin>>t;
    while(t--)
    {
         
          cin>>n;                  
                jishu=0;
                int tem = 0;
                long long now = 0;
                for( i=0;i<=20;i++)
                dp[i]=-1;
                for(i = 0 ; i < n ; i++)
                {
                      cin>>m;
                      for(j = 1; j <= m - tem; j ++)
                      {now++;
                      a[now]='(';
                      }
                      tem = m;
                      now++;
                      a[now]= ')';
                } 
                //for(i=1;i<=now;i++)
                //cout<<a[i]<<" ";
                for(i=1;i<=now;i++)
                {
                   if(a[i]==')')
                   {
                     sum=0;
                         for(j=i-1;j>0;j--)
                          {
                              if (a[j]=='(')                           
                              {
                                  if (dp[j]==0)
                                    sum=sum+1;
                                   else
                                   {  
                                     dp[j]=0;
                                    jishu=jishu+1;
                                     if (jishu!=n)
                                          cout<<sum+1<<" ";
                                     else
                                          cout<<sum+1<<endl;
                                    break;        
                                   }
                              }              
                        }                             
                    }
              }
                
              
   }
    
    //system("PAUSE");
    return EXIT_SUCCESS;
}

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