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

自己测试都对,提交总是WA,求大神指点

Posted by 2597089499 at 2014-05-29 01:01:36 on Problem 1007
#include <iostream>
using namespace std;
struct
{
    char str[51];
    int next;
} arr[1100];
int top=700;
#define New(x) {x=top++;arr[x].next=-1;}

int main()
{
    //freopen("1007.in","r",stdin);
    for(int i=0; i<100; i++)
    {
        arr[i].str[0]=0;
        arr[i].next=-1;
    }
    int m,n;
    cin>>m>>n;
    for(int i=0; i<n; i++)
    {
        char temp[51];
        cin>>temp;
        int A,C,G,T;
        A=C=G=T=0;
        int srt=0;
        for(int j=m-1; j>=0; j--)
            switch(temp[j])
            {
            case 'A':
                A++;
                break;
            case 'C':
                C++;
                srt+=A;
                break;
            case 'G':
                G++;
                srt+=A+C;
                break;
            case 'T':
                srt+=A+C+G;
                break;
            }
        if(arr[srt].str[0]!=0)
        {
            while(arr[srt].next!=-1) srt=arr[srt].next;
            New(arr[srt].next);
            srt=arr[srt].next;
        }
        int j;
        for(j=0; j<m; j++)
            arr[srt].str[j]=temp[j];
        arr[srt].str[j]='\0';
    }
    int cnt=0;
    for(int i=0; ;i++)
    {
        if(cnt==n)
            break;
        if(arr[i].str[0]!=0)
        {
            int t=i;
            do
            {
                cout<<arr[t].str<<endl;
                t=arr[t].next;
                cnt++;
            }while(t!=-1);
        }
    }
    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