| ||||||||||
| 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 | |||||||||
1785我的老是WA#include <iostream>
using namespace std;
int d[51000],a[7][51000],i,j,k,l,n,m,tmp;
char ch[51000][200],s;
void qsorth(int l, int r)
{
if (l>=r) return;
long i=l;
long j=r;
long mid=a[6][(l+r)/2];
while (i<=j)
{
while (a[6][i]<mid) i=i+1;
while (mid<a[6][j]) j=j-1;
if (i<=j)
{
tmp=a[6][i];a[6][i]=a[6][j];a[6][j]=tmp;
tmp=a[5][i];a[5][i]=a[5][j];a[5][j]=tmp;
++i; --j;
}
}
qsorth(l,j);
qsorth(i,r);
}
int main()
{
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
scanf("%d",&n);
while (n!=0)
{
for (i=1;i<=n;i++)
{
scanf("%c",&s);
while ((s>'z')||(s<'a'))
scanf("%c",&s);
ch[i][0]='\0';d[i]=0;
while ((s>='a')&&(s<='z'))
{
d[i]++;
ch[i][d[i]]=s;
scanf("%c",&s);
}
scanf("%c",&s);
while (s>'9' || s<'0')
scanf("%c",&s);
a[2][i]=s-'0';
while ((scanf("%c",&s)!=EOF)&&(s>'0' && s<'9'))
{
a[2][i]=a[2][i]*10+s-'0';
}
a[6][i]=a[2][i];
}
for (i=1;i<=n;i++)
a[5][i]=i;
qsorth(1,n);
for (i=1;i<=n;i++)
{
if (a[5][i]>1 && a[2][a[5][i]-1]<a[2][a[5][i]])
{
a[0][a[3][a[5][i]-1]]++;
a[3][a[5][i]]=a[3][a[5][i]-1];
a[0][a[5][i]]=0;
}
else {
a[0][a[5][i]]=1;
a[3][a[5][i]]=a[5][i];
}
if (a[5][i]<n && a[2][a[5][i]+1]<a[2][a[5][i]])
{
a[1][a[4][a[5][i]+1]]++;
a[4][a[5][i]]=a[4][a[5][i]+1];
a[3][a[4][a[5][i]+1]]=a[3][a[5][i]];
a[1][a[5][i]]=0;
}
else {
a[1][a[5][i]]=1;
a[4][a[5][i]]=a[5][i];
}
if (a[5][i]>1 && a[2][a[5][i]-1]<a[2][a[5][i]])
a[4][a[3][a[5][i]-1]]=a[4][a[5][i]];
}
for (i=1;i<=n;i++)
{
for (j=1;j<=a[0][i];j++)
printf("(");
for (j=1;j<=d[i];j++)
printf("%c",ch[i][j]);
printf("/");
printf("%d",a[2][i]);
for (j=1;j<=a[1][i];j++)
printf(")");
}
printf("\n");
scanf("%d",&n);
}
}
AC了的大牛可以给我一个WA的样例吗,谢谢!
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator