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 6729763 at 2011-04-19 09:29:29
题目:http://acm.nankai.edu.cn/p1847.html
我下载了这个题目的测试数据,测试都通过了,为什么还是WA呢?能不能帮忙看下,看看小弟的问题在哪,谢谢了

代码:

#include <iostream>
#include<string>
#include<stack>
using namespace std;

struct prob
{
       int name;
       int len;
       stack<string> catn;       
};
struct act
{
       string name;
       int len;
       stack<int> catn;       
};
int main ()
{
    int probnum = 0;
    int actnum = 0;
    cin>>probnum;
    prob *a = new prob[probnum];
    string tmps;
    char tmpc;
    int tmpi;
    stack<string> tmpq;
    for(int i = 0; i<probnum; i++)
    {
         cin>>a[i].name;
         //cout<<a[i].name;
         a[i].len = 0;
         while(1)
         {
              cin>>tmps;
              a[i].catn.push(tmps);
              a[i].len++;
              tmpc = cin.get();
              if(tmpc=='\n')
              break;       
         }    
    }
    
    cin>>actnum;
    act *b = new act[actnum];
    for(int i = 0; i<actnum; i++)
    {
         cin>>b[i].name;           
    }
    for(int i = 0; i<actnum; i++)
    {
         b[i].len = 0;
         for(int j = 0; j<probnum; j++)
         {
                 
                 string *c = new string[a[j].len];
                 tmpq = a[j].catn;
                 for(int n = 0; n<a[j].len; n++)
                 {
                         c[n] = tmpq.top();
                         tmpq.pop();       
                 }
                 for(int m = 0; m<a[j].len; m++)
                 {
                        if(b[i].name==c[m])
                        {
                              (b[i].len)++; 
                              b[i].catn.push(a[j].name);                 
                        }       
                 } 
                 delete []c;       
         }        
    }
    
    for(int i = 0; i<actnum; i++)
    {
         if(b[i].len==0)
         cout<<"Error"<<endl;
         else
         {
           cout<<b[i].len;
           int *storg = new int[b[i].len];
           for(int j = 0; j<b[i].len; j++)
           {
               storg[j]=b[i].catn.top();
               b[i].catn.pop();
           }
           for(int j = 0; j<b[i].len-1; j++)
           {
                for(int m = j; m<b[i].len; m++)
                {
                     if(storg[j]<storg[m])
                     {
                           tmpi = storg[m];
                           storg[m] = storg[j];
                           storg[j] = tmpi;                    
                     }        
                }       
           }
           for(int j = 0; j<b[i].len; j++)
           {
                   cout<<" "<<storg[j];       
           }
           cout<<endl;
           delete []storg;
         }
         
    }

delete []b;
delete []a;
//system("pause");
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