tsp_individual_multi::DNA tsp_individual_multi::translateToDnaPhenotypicOrdinal(const DNA trait){ DNA ordinal; DNA tmp; for(int i=0;i<trait.size();i++){ tmp.push_back(i); } ordinal.resize(trait.size()); for(int i=0;i<trait.size();i++){ ordinal[i] = tmp[trait[i]]; tmp.erase(tmp.begin() + trait[i]); } return ordinal; }
int main() { #ifndef ONLINE_JUDGE freopen("in_2945.txt","r",stdin); #endif four[0]=1; for(int i=1;i<=20;++i) { four[i]=four[i-1]*4; } while(scanf("%d%d\n",&n,&m)&&n) { dna.clear(); memset(cnt,0,sizeof(cnt)); for(int i=0;i<n;++i) { //scanf("%s\n",&buf); gets(buf); long long tmp=0; for(int j=0;j<m;++j) { tmp+=four[j]*GetW(buf[j]); } mit=dna.find(tmp); if(mit==dna.end()) { dna[tmp]=1; } else { dna[tmp]++; } } for(mit=dna.begin();mit!=dna.end();++mit) { cnt[mit->second]++; } for(int i=1;i<=n;++i) { printf("%d\n",cnt[i]); } } return 0; }
tsp_individual_multi::DNA tsp_individual_multi::translateToDnaPhenotypicTrait(const DNA ordinal){ DNA trait; DNA tmp; for(int i=0;i<ordinal.size();i++){ tmp.push_back(i); } for(int i=0;i<ordinal.size();i++){ for(int j=0;j<tmp.size();j++){ if(ordinal[i] == tmp[j]){ trait.push_back(j); tmp.erase(tmp.begin() + j); break; } } } return trait; }