| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
哪位大侠能帮忙看一下,都快疯了题目: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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator