| ||||||||||
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 |
大牛帮忙看看哪里错了??#include<stdio.h> struct st { int pos,val; }a[200010]; int b[200010],p[200010],c[1001],first[1001]; int main() { int i,j,k,t,r,e,f,n,cnum; while(scanf("%d",&n)!=EOF) { if(n == 1) { scanf("%d%d",&e,&f); printf("%d\n",f); continue; } cnum = (n + 199)/200; for(i = 1;i < cnum ;i++) { c[i] = 200; first[i] = 1 + (i-1)*200; } if(n%200) c[cnum] = n%200; else c[cnum] = 200; first[cnum] = 1 + (i-1)*200; for(i = 1;i <= n;i++) p[i] = 0; for(i = 1;i <= n;i++) scanf("%d%d",&a[i].pos,&a[i].val); b[a[n].pos+1] = a[n].val; p[a[n].pos+1] = 1; for(i = n-1;i >= 1;i--) { j = 1; while(a[i].pos + 1 > c[j]) { a[i].pos -= c[j]; j++; } t = 0; r = j; f = first[r] + 199; if(r == cnum) f = n; for(k = first[r];k <= f;k++) { if(p[k]==0) t++; if(t == a[i].pos + 1) break; } c[r]--; b[k] = a[i].val; p[k] = 1; } for(i = 1;i < n;i++) printf("%d ",b[i]); printf("%d\n",b[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