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

暴力16ms

Posted by Alanqky at 2014-09-17 15:41:37 on Problem 1007
#include<stdio.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<iostream>
#include<stack>
#include<cmath>
using namespace std;
typedef struct st
{
     char s[110];
     int m;
}st;
int cmp(st a, st b)
{
   return a.m<b.m;
}
st a[60];
int main(void)
{
   int n,m;
   
   while(scanf("%d %d",&n,&m)!=EOF)
   {
       for(int i=0;i<m;i++)
       {
         getchar();
         scanf("%s",a[i].s);
       }
       for(int i=0;i<m;i++)
       {
         a[i].m=0;
         for(int j=0;j<n;j++)
         {
           for(int k=j+1;k<n;k++)
           {
             if(a[i].s[j]>a[i].s[k])
               a[i].m++;
           }
         }
       }
       sort(a,a+m,cmp);
       for(int i=0;i<m;i++)
       {
         printf("%s\n",a[i].s);
       } 
   }
   //int c;
   //cin>>c;
   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