1#include <iostream>2#include <cstdio>3#include <string>4#include <algorithm>5 using namespacestd;6 7 BOOLcmpstringAstringb);8 BOOLMatchstringAstringb);9 Ten One intMainvoid) { A inttestsize, couple; - stringstr[101]; - intlen[101]; the BOOLused[101]; - - //For each test case: (t<=20) -CIN >>testsize; + while(testsize--) { - //Scan and Store n strings (n <=) +CIN >>couple; A for(inti =0; i < couple; ++i) { atCIN >>Str[i]; - } - - //Sort by length -Sort (str, str +couple, CMP); - //sort (< #_RandomAccessIterator __first#>, < #_RandomAccessIterator __last#>, < #_Compare __comp# >) in - for(inti =0; i < couple; ++i) { to //Store Length +Len[i] =str[i].size (); - //Init used theUsed[i] =false; * } $ Panax Notoginseng intCount =0; - the for(inti =0; i < couple; ++i) { + if(!Used[i]) { A for(intj = i +1; J < couple && Len[j] = = Len[i]; ++j) { the if(Match (Str[i], str[j]) &&!Used[j]) { +count++; -Used[i] = used[j] =true; $ Break; $ } - } - } the } - Wuyicout << Count <<'\ n'; the } - Wu return 0; - } About $ BOOLcmpstringAstringb) - { - returnA.size () >b.size (); - } A BOOLMatchstringAstringb) { + intLen =a.size (); the for(inti =0; i<len; i++) { - if(A[i] = ='A'&& B[i]! ='T') $ return false; the if(A[i] = ='T'&& B[i]! ='A') the return false; the if(A[i] = ='C'&& B[i]! ='G') the return false; - if(A[i] = ='G'&& B[i]! ='C') in return false; the } the return true; About}
Sicily 1035. DNA Matching