Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- struct data
- {
- int counter;
- int index;
- } ans[1003];
- char store[1003][1003];
- bool cmp(data l,data r)
- {
- return l.counter<r.counter;
- }
- int main()
- {
- int koyta,len,i,j,counter;
- while(scanf("%d%d",&koyta,&len)==2)
- {
- for(i=1; i<=koyta; i++)
- {
- scanf("%s",store[i]);
- }
- for(i=1; i<=koyta; i++)
- {
- counter = 0;
- for(j=0; j<len; j++)
- {
- counter += (store[1][j]!=store[i][j]);
- }
- ans[i].counter = counter;
- ans[i].index = i;
- }
- sort(ans+1,ans+koyta+1,cmp);
- for(i=1; i<=koyta; i++)
- {
- printf("%s\n",store[ans[i].index]);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment