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 |
有一个梦想用暴力方法就能过的……要事情是这么简单的话,ICPC还有人愿意参加么In Reply To:太郁闷了,为什么老是说超时啊??? Posted by:hot at 2005-05-16 23:23:30 > #include <iostream> > #include <string> > #include <cassert> > #include <cstdlib> > > using namespace std; > > int main() > { > int n, loop; > int i, j; > > cin >> n; > string message(n, ' '); > string message2(n, ' '); > > int * num = new int [n]; > int * ntemp = new int [n]; > assert( num != 0 && ntemp != 0); > > for (i = 0; i < n; i++) > cin >> num[i]; > > while(1){ > cin >> loop; > cin.ignore(); > char c[201]; > cin.getline(c, 200); > for (i = 0; i < strlen(c); i++) > message[i] = c[i]; > // getline(cin, message); > > if (loop == 0 && message[0] == '0' && strlen(c) == 1){ > delete [] num; > delete [] ntemp; > return 0; > } > > for (i = 0; i < n; i++){ > ntemp[i] = i + 1; > } > > for (i = 0; i < loop; i++) { > for (j = 0; j < n; j++){ > ntemp[j] = num[ntemp[j] - 1]; > } > } > > for (i = 0; i < n; i++){ > message2[ntemp[i] - 1] = message[i]; > } > for (i = 0; i < n; i++) > cout << message2[i]; > > cout << endl; > > message = string(n, ' '); > } > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator