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啊!高手帮忙看一下吧,多谢了c代码: #ifndef DEBUG DEBUG = 0; #endif #include <stdio.h> #include <stdlib.h> void main(){ char s[5100]; unsigned int c[200]; int n,m,M; int count=0,i,j; FILE *fp; if(DEBUG){ n=50;m=100; } else{ scanf("%d %d",&n,&m); } fflush(stdin); M=m; memset(c,0,200*sizeof(unsigned int)); while(m--){ if(!DEBUG){ scanf("%s",s+m*(n+1)); fflush(stdin); } else{ for(i=0;i!=n;++i){ switch(rand()%4){ case 0:memset(s+m*(n+1)+i,65,sizeof(char));break; case 1:memset(s+m*(n+1)+i,67,sizeof(char));break; case 3:memset(s+m*(n+1)+i,71,sizeof(char));break; case 2:memset(s+m*(n+1)+i,84,sizeof(char));break; default:memset(s+m*(n+1)+i,84,sizeof(char));break; } } //memset(s+m*(n+1),65,n*sizeof(char)); s[m*(n+1)+50]=0; } count=0; for(i=m*(n+1);s[i]!=0;++i){ if(s[i]!='A'){ for(j=i+1;s[j]!=0;++j){ if(s[i]>s[j]) count++; } } } c[m+100]=count; c[m]=m; i=m; while(i<M-1){ if(c[i+100]>=c[i+1+100]){ j=c[i+100]; c[i+100]=c[i+1+100]; c[i+1+100]=j; j=c[i]; c[i]=c[i+1]; c[i+1]=j; } i++; } } if(DEBUG) fp=fopen("c:\\out.txt","w"); for(i=0;i!=M;++i){ for(j=0;j!=n;++j) if(!DEBUG) printf("%c",s[c[i]*(n+1)+j]); else{ fprintf(fp,"%c",s[c[i]*(n+1)+j]); } if(DEBUG) fprintf(fp,"\t%d",c[i+100]); if(i!=M-1) if(!DEBUG) printf("\n"); else fprintf(fp,"\n"); } if(DEBUG) fclose(fp); else scanf("%d",&count); } debug为1可以生成 c:\out.txt,里面是伪随机生成的100条50字符的序列,每行后面是逆序数。不知道错在哪里了,高手帮下忙吧 out.txt : ATCACCAAATAGAAAAGAGATAGTCTCTAAGTCTGTGGTATACTGGTTTT 262 AACCTTAAGATAGCTCACCGATCATGAAATTTCGCATCCTGTGCGTTTGA 348 ACCACGCACCGAGGGCTTTGACGAGGATTTGATTCGCTATGAGAGTTGCG 349 ATGCAATCTCCGCCATCACACCGCCCGAAGCTATTACCAGGGGGGAGTGT 372 TGCAGGACACTCGCCTAGTCATCCCGCCTAATCTCCTTACTGCGGGCGTT 374 GAGCCTCTCAGACATAGCTGGAACCGCGAGCATGAGTCAGTCGTAGGTGT 377 TCACCAATCCACAATATCTGAGGCGACGGGTGGTACTCTTTTGGAGGAAC 386 AATCATTCCAGAAGGTCACAGACCAAGTGTCTAATACTTTGGCGGAGGCG 387 CAAGGGGACTCAGCCGAGACCAAAGGATGTACGCTTAGCGTGCCGCGCAG 391 CCACCCGTCGATTAGCAACTCGTGTAGAGTATGCCTGCGTGTTGGACAGG 392 ACTACAGGCACATTGCGGCGTATCCACCCAACGTCCCTAGGCTGGTCATC 395 CACTCATAGCGCCACGATAACCACATATAACATGGGCCGCCCATGCATCT 395 CAGGACGATGAAACCTGCCGGGTGAATTAATCCTCCATTATGTCTGGAAG 397 ACCATTCTACACGGGGCTAAAGCCGGGGATAAGCTCGTCGTCACACGTTG 397 GCTTAAGATTAACGTGAGATTCTTCGTTTGCGCTCAGTTACTGCTTTTCA 400 GGAAAAAGCCCGGAACCGAGGTCGTAGTAATCCTCATGCACCCGCGCCGA 401 AAGGATTCAACCTACGAAATCGATACTTGGTGATACGTGCCTACGGCACT 403 AAACTCTAAGAGAATAGAACTTCTCGTCCGAATTGTCTGCCGTACGACCA 405 ATACCCACGATCTGGCCCACTATTTGTCGCAAAAGACGTGATTGGCATGG 409 TGCATAACATAAGAGAACGCGCCAAAGGTCGATTCGATGAAGGCGTACAG 410 CTTTCAATCCGTCTAGAGCATTCCTCTTATGCTGTCCTTATTAGCTGCTC 410 ATAGCAAAGCAGAGAAGCGGGCAGCTAGAAGCGAGATACAGTCTAACTAA 412 CACACATTCGAAAGTGCGGGACGCAGGAGCCGCCATAACTTATTCGTAAG 414 AGCTGGGTCGTAATCACCAAGACTGCCCTAAGGGCATTGTCTCTTCCTCC 416 ACACTTAGAACGCAAGCTGACGCCGAGGACCGGACGAACCCAGTAATCCT 419 CGGTACCCCAGAGGTAGGATATTAGCAATAGGACAATTTCCGAAGGATTT 424 CTCACTCTCAGGTGGGGTCCTGCAGTACATCTAGCCTCTTCATGTCTGCG 426 CTTCCCGGCTGCTCCTTAAGAACGTACGCAGGCGCCCCTGCTAGGGCTGT 427 GGATGGGCCTTTACGTGGGTGCTGTCGTGCCAATTGTTCTACCTGTGTAT 427 TCAGATCCTCAAAGTGGACTTTTTACTGGGCGGATTCACTCACCTGTCCT 429 AGCTAGGCTAGTATCCCATGCATCGGCCAAAGGTTGGTACCCCCTTTAGG 429 TTCACTGCAACCACGGCAATTGCCTTTTTTCACATCAGCATTTAGTTAGA 432 AGCGCGCTGGTCGGTGAGTATGACGTGGAGGAGGAGTGAGGCGTCATTCC 439 GATTGGCTTCACTGTACGTAGCGGAGATACGTCCGATCAGTTTGTGAGTG 441 GTGCAACACGTCTTATGTACATCACACTCGTAATACTTGCTGATGCGCTA 441 GTCTCGACATCAGAAGACTGTTGGAGTGTTCTCCGATAGTCGTAATAGCT 442 TCACATTGGTCCGCCAGGTCTCAAAGTGGCATGCCATAATATGTGGCGTG 443 AAGAGTGTTAGACGTGTTGTTATCTTTACCGTTGTTAATGAATAGGTGAC 447 CAATGATTGTGAATTTCGGGAGGATAAAGGTGATCGTAGTAGATAGATTC 448 ACAACGTCCACATCGGGAGCCCTCCGCATCATGTTCAGTGCGCCAAACCA 448 CGCTTCGAGCCTGCAGACCCCGCAGGCTTCCGTTGGCCATGGGAGCCCGA 451 CGATTCTAGAATTCAGAAAGAGGCCCCATACGATAACTGATTCCTGAGAG 453 GATCCGGCCTAGTTATATAATCTCTTTCCACGATAATAGAAGTGCTTTCC 453 GAGACCTAATTGCAATCTCACGTCACCTGGTATTGGCAATTCAATCAATC 454 CTGAACTACGTGGCGAGACCGACCCGATTTAAGACTTTGCGAAGCTATGA 454 AATTGGTAGTACTTTCATACCACCTACTTACAGTGCGGTGACAGGGTTAG 456 GCACTTTTAGCGAATCGCTCTGCACACCCGTGTAGTCAGGCGCGTCAGGG 457 GCGGCTTTGCATCTACAACATCTGCCACTCGAGCTGGATCCTTTAGAGCT 458 GCCTGAATGTTGACCGGTGCTCCAAATTCAGGTGATTACGCATTGGAGCT 463 AGATAGCGTACCGACATGGCCCAAGCATAACACAGCCGAAAGATAGGGCC 463 TTATTCCTACCATGCCCAGCGTAGCATAAGGACTTCGAGGACCCTTCTGC 466 ATGAGCTCTAGACTATGATGATGGCGAGGTAAAGTGGTGTATCTTACCAA 466 TCATCTAACTCGACTGGGCTTGAGCGTAGTTTAGAGACAATAGATGGCGT 466 TTGTACTCGACTCACTCTCTAGCGAAATAATTGATGACAACTTTTAATCT 471 CAGCCCAATGATTTTGTATGGATATGATACTGCCCGTTGTCAAGAATGAG 472 AGCGAACTCCTCCTGAATGGACACGCGAACCACGGCCACTCCGGCAACAG 472 TCACGCTAGTCACGACTCCCTCTATGCCCCCACCGTATATATCCAGCCAG 473 TTGCGGTCAGTGCGCTGCCACCGTTCGCGGGGAGTATCTCAAGTTATGCT 474 CGGTATCTCTCCAATCCCCATTCAGGGTGATTCATTGGGCCGCGCCCTCA 474 CGTACATTTACCCGCGGTGAGATCATCATGGTGTCAGGGTGGTCCACGCA 475 TAACCTTTCCTTCGATGACGCACTACGGCCCGCAACCGTGCGTACGCATG 475 GGATGCAATACAATACCCCTGTATAATCAATAAGCTGCCGGGACAGAACC 479 GGACAGCCATGTTAATCTATTAGTATGGTGAACGTAAACGTGTGGAAACG 479 ATGATCTTACGAATTGGGCGGAAACTTCTCTAATTCTCGAGCCATCCTCC 480 TGAGACACGATGACTCGTTTGTTCACGGTTCAGTTCGAAGCCTCCTCGAA 488 TTCCTTATGCAAAAATGCTCAATCCTTCCTGCCACGTTCGAACAGATTAG 488 ATTAATTCTCGGCTCCCGCGACTCCTGCAAGCTCGGCGGATTATAGGTAA 489 CATCTATGGCTGAGGGCCAACCTCTTCTCTACGCGCCCTAGACGGGTGAA 493 TAGAGTTTGGAGCGTGTGCAATGCGATATCGGGTTGAAGACGCATTCTGC 493 AGGTCTCCAAGGCTAGTTGCGCCAAGATGCTAAATTCCACTAGCCAACTT 498 AGAATGGCCTCGCGATTGCCACCTCCTCGCCGGGTAACACATAAGAACTT 500 TCCTGGCGACACAGTTGGTAAGCTGCGTTGTGTGGGAATAACTTTCCAAA 502 GTGTTTTGATGCAAACTTAACAAGACGGATAGTGGAGCGCCGTGACCTCT 502 CTGCTCCCTTGAAGTTTCGGCGCTGGATAGCTTTGATACCAGCGTGCTAC 505 TTCGCTAATCCTCCACGGTCGGAGCCTAAGCACCCGGCGGCATATAATGC 508 AAATTGGGTCCGCTTTTTCCAAATCTGTGAAACCCAAATTTGCAGAGCTC 508 TCTGCCCTCATCGTCAGGACGTCGAACCTTTGTGTAACACCGACCATCCT 508 AATTCAGCTAGGCGCTAGCGGTGAACTATATCGAAATTCGAATAACTAAC 510 AGGTATGTCTTAGAGAATGCGTGAGAGTTAAGTATCATCCGTCAAGAGAG 512 AGTTCATGTCGAAGGGGTCTCGCAGGACCATAAACATAATCGATAGCTGG 513 ATTGCTATGTAGCTACTCGTTTGCCATCTGGCCTAACTAACGTCATAGTG 513 ACGGTTATGGCTTGTACATATCAACCATCAGCGCGCAAAAGCTAGAATTT 515 TCGTGATTAGAGTAATCAGTGGGCTGTACTGTGATGCATACCACTCCCTC 517 ATTTGACAGGCATGAGTCCCCCCAGTCCTAGTAGACACCATTACAGTACC 519 GCATTTGTTCGATAGAAGATTCTGAGGTACTTCGCTCGCAGATTGACCGC 519 TGCTGATAACCTAGACGTACGTTAGACCCGTGAAAGCGCTCGAGAAGTAA 521 TTTTCAAGTGTGACAGGCTTGATAACAGAACTCGTTAAGGACAGGCTCCT 522 ACCGGATGATGTTCTGGACAGATTTCCGGGACCCCTTCCGGTGCACCAAC 524 TTAGATTTGCCTAACTTGCGCAACGAATGCCACCGGTCTCATCCAACTCC 533 TTCTATAGGCGGTTCACAACCACTGGAATAGCTGCGCGACACTTCCTAAC 533 GGGATGAGTGAGACCCGACTATCATCTAGCGCCAGCCCCTGCCAAGCCAC 535 TCGGCAGTGGACATCGCTGCCTGAGAAGCAGCAAGCCCTTAACCGCGCCA 544 TTGCGGGCCCTTGCGCTGGCTTGCACGAGGTCCCGAGGGGGAGAACCTGC 546 CCTGTCTGGTTCTGATGTGTTATGGACTTGATTCCGCCACATCCCATGTC 547 AATATTGGGGCATAAGAGTCACTTCGCATGGACACACGCTAACACAGAGA 548 TTTGTAGTCAGTTTAATCTGGCTCCTTTTCGAGTCGCGTTCATAAACATG 551 TTTGGCTATTTCACTACTATATGATTTACGGGCGTAGGACACCCAGTTGC 553 TGCGGCCTTTCGTTGCCTCTACACTACACCGGTTGCATAGACACGATTCA 569 AATTTTGCGTCGAGTCCCCTCGTCGCTGATCTACGGCAACTCATCACTAA 571 GGTTTCTCTTTTGTAACGGTCCGGCAGCGAACAAAAGGGCAAATCAAAAT 684 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator