Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:求助!测试数据都对,提交上去就是WA。。

Posted by 1622202469 at 2014-07-11 20:18:47 on Problem 1007
In Reply To:求助!测试数据都对,提交上去就是WA。。 Posted by:kevinye0108 at 2014-07-08 17:19:01
> 用数组首位记录逆序数,算法比较低级。。
> 
> #include <iostream>
> using namespace std;
> 
> int main()
> {
>     int leng, num;
>     
>     cin >> leng >> num;
>     char** dna = new char*[num];
>     for(int i = 0; i < num; i++) dna[i] = new char[leng+2];
>     
>     int row, col;
>     int prev;
>     for(row = 0; row < num; row++){
>         dna[row][0] = '0';
>         for(col = 1; col <= leng; col++){
>             cin >> dna[row][col];
>             for(prev = 1; prev < col; prev++)
>                 if(dna[row][prev] > dna[row][col]) dna[row][0]++;  //unsortedness increase;
>         }
>         dna[row][leng+1] = '\0';
>     }
>     char* temp;   //start comparing;
>     
>     for(int j = 0; j < num - 1; j++){
>         row = num - 1;
>         while(row > j){
>             if(dna[row][0] < dna[row-1][0]){
>                 temp = dna[row-1]; dna[row-1] = dna[row]; dna[row] = temp;
>             }
>             row--;
>         }
>     }
>     
>     for(row = 0; row < num; row++){
>         for(col = 1; col <= leng; col++) cout << dna[row][col];
>         cout << endl;
>     }
>     
>     return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator