| ||||||||||
| 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 | |||||||||
过了的,帮忙看下啊,为什么wa啊,是我理解错了还是撒的``谢谢了!#include <stdio.h>
#include <algorithm>
char a[50000][8];
typedef unsigned short sh;
struct menber
{
sh p,n,m;
}b[50000];
sh r[50000],t[50000];
bool cmp(const sh &x,const sh &y)
{
return r[x]>r[y];
}
void inline run(sh x,sh y,sh l)
{
sh i;
b[x].p++; b[y].n++;
if(x==y) return;
for(i=l;;i++) {if(t[i]>=x&&t[i]<=y) break;}
if(t[i]!=x) run(x,t[i]-1,i+1);
if(t[i]!=y) run(t[i]+1,y,i+1);
}
int main()
{
sh n,i,j;
char c;
while(scanf("%d",&n)&&n)
{
for(i=0;i<n;i++)
{
getchar();
j=0;
c=getchar();
while(c!='/') {a[i][j++]=c; c=getchar();}
a[i][j++]='/'; a[i][j]='\0';
b[i].p=0; b[i].n=0;
scanf("%d",&b[i].m);
r[i]=b[i].m; t[i]=i;
}
std::sort(t,t+n,cmp);
run(0,n-1,0);
for(i=0;i<n;i++)
{
while(b[i].p--) putchar('(');
printf("%s%d",a[i],b[i].m);
while(b[i].n--) putchar(')');
}
putchar('\n');
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator