strings是谁,unsigned short int
timelimitpertest2secondsmemorylimitpertest 256 megabytesinputstandardinputoutputstandardoutput
somedwarvesthatarefinishingthestudy (stateuniversityfordwarvenyoungsters ) Bachelor courses,have been told 'no genome, o degree '.thatmeansthatalldwarvesshouldwriteathesisongenome.dwarvengenomeisfarfromsimple.itisrepresentedbyastringthatcongcomple
dwarfmishahasalreadychosenthesubjectforhisthesis 3360 determiningbytwodwarvengenomes、 whethertheybelongtothesamerace.twodwarvesbelongtothesameraceifwecanswaptwocharactersinthefirstdwarf ' sgenomeandgetthesecond dwarfmishaandfindoutwhetwognomesbelongtothesameraceornot。
inputthefirstlinecontainsthefirstdwarf ' s genome : anon-empty string,consistingoflowercaselatinletters。
thesecondlinecontainstheseconddwarf ' s genome : anon-empty string,consistingoflowercaselatinletters。
thenumberoflettersineachgenomedoesn ' texceed 105.itisguaranteedthatthestringsthatcorrespondtothegenomesaredifferent.the give
输出打印' yes ',ifthedwarvesbelongtothesamerace.otherwise,打印' no '。
sampletest(s ) inputabbaoutputyesinputaaboutputnonote
first example 3360 youcansimplyswaptwolettersinstring ' ab '.sow eget ' ba '.second example 3360 we can ' tchangestring ' aa ' iing
解答问题说明:这个问题是判断一个字符串是否通过调整其中两个字符的顺序成为另一个字符串。 可以先数一下原来两个字符串中不同的地方,看看两个位置的字符是否不同,然后把两个字符串中的字符按从小到大的顺序排列,看是否相同。 如果原始字符串确实只有两个位置不同,排序后的两个字符串相同,则可以证明通过转换得到。
# include iostream # include cstdio # includecstdlib # include cmath # include cstring # include string # include string # includeall int i,c=0; cin a b; for(I=0; Ia.size(Ib.size ); I () if ) a[I]!=b[I]({c; }sort(a.Begin ),a.end ); sort(b.Begin )、b.end ); if(a==BC==2) printf(yes\n ); }else{printf(no(n ); }return 0; }