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 |
wrong answer, but i dont understand whywhy is not it correct ? Can somebody find an input such that the output is wrong ? Thanks #include <cstdio> using namespace std; int main() { int N, L, M, i, j, k, l, o; scanf("%d %d", &L, &N); char** dnas = new char*[N]; int* Ms = new int[N]; memset(Ms, 0, sizeof(Ms)); for (k = 0; k < N; k++) { dnas[k] = new char[L]; scanf("%s", dnas[k]); //dnas[k] += '\0'; for (i = 0; i < L; i++) { for (j = i+1; j < L ; j++) { if (dnas[k][i] > dnas[k][j]) Ms[k]++; } } if (k > 0) { o = k; for (l = k-1; l >= 0; l--) { if (Ms[l] > Ms[o]) { swap(Ms[l], Ms[o]); swap(dnas[l], dnas[o]); o = l; } } } } for (k = 0; k < N; k++) { printf("%s\n", dnas[k], Ms[k]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator