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 又 re 到最后 ac.给后来者分享一点教训wa 是因为没有考虑 k1,k2,k3 rotate过头的情况。 re 是因为 ki %= top 时要考虑 top 为 0 的情况。 附核心代码: ts = ""; top = 0; for(int i = 0 ;i < len;++i){ if(a[i]>='a' && a[i] <='i'){ pos[top] = op[top] = i; ++top; } } if(top != 0){ k1 %= top; for(int i = top - k1;i < top;++i) ttt[i - top + k1] = pos[i]; for(int i = top-1 ;i >= k1;--i) pos[i] = pos[i-k1]; for(int i = 0 ;i<k1;++i) pos[i] = ttt[i]; for(int i = 0 ;i < top;++i) ts += a[pos[i]]; for(int i = 0 ;i< top;++i) a[op[i]] = ts[i]; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator