阅读 75

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; }


文章分类
代码人生
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐