| ||||||||||
| 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 | |||||||||
Re:请各位大虾多多帮忙一下啊,我今天下午搞了一个下午了,我想到的数据都过了,但是一提交就是WA掉了,究竟是为什么啊!!In Reply To:请各位大虾多多帮忙一下啊,我今天下午搞了一个下午了,我想到的数据都过了,但是一提交就是WA掉了,究竟是为什么啊!! Posted by:yangyangscut at 2009-07-13 19:14:56 > 这是我的程序,贡献了无数次的WA,希望有人可以帮下我,不胜感激^^
> #include <iostream>
> using namespace std;
>
> int main()
> {
> int f[25],p[25],w[25];
> int t,i,j,k,m,n;
> cin>>t;
> for (i=0;i<t;i++)
> {
> cin>>n;
> for(j=0;j<n;j++)
> {
> cin>>p[j];
> if(j==0)f[j]=p[j];
> else f[j]=p[j]-p[j-1];
> }
> if(n==1)cout<<"1"<<endl;
> else if(n==2)cout<<"1 2"<<endl;
> else {
> w[0]=1;
> w[n-1]=n;
> for(j=1;j<n-1;j++)
> {
> if(p[j]!=p[j-1]){w[j]=1;f[j]--;}
> else {
> m=1;
> for(k=j-1;k>=0;k--)
> {
> m++;
> if (p[k]!=p[k-1]&&f[k]>0)
> {
> w[j]=m;
> f[k]--;
> break;
> }
> }
> }
> }
> for(j=0;j<n;j++)cout<<w[j]<<" ";
> cout<<endl;
> }
> }
> return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator