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 |
我O(N^2)的算法 100+MS过了,代码仅17行。。。。我O(N^2)的算法 100+MS过了,代码仅17行。。。。 #include <iostream> using namespace std; int a[8100],f[8100],n; int main(){ int i,j,k; scanf("%d\n",&n); a[1]=1; for(i=2;i<=n;i++){ scanf("%d\n",&k); k++; for(j=i;j>k;j--)a[j]=a[j-1]; a[k]=i; }; for(i=1;i<=n;i++)f[a[i]]=i; for(i=1;i<=n;i++)cout<<f[i]<<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