B1. Character Swap (Easy Version) This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems. After struggling and failing many times, Ujan decided to tr…
题意:给你两个字符串,问是否存在交换方案使得两个字符串变成一样的,方案为只交换一次且只交换s1与s2里的一个字符 题解:若一开始就相同,则存在交换方案 若一开始不同的位置为1个或大于2个,则不存在方案 若一开始不同的位置为2个,则看ai==aj 或 bi==bj,只要满足其中一个就存在方案,否则不存在方案 #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #incl…
This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems. After struggling and failing many times, Ujan decided to try to clean up his house again. He…
B2. Character Swap (Hard Version) This problem is different from the easy version. In this version Ujan makes at most 2…
This problem is different from the easy version. In this version Ujan makes at most 2n2n swaps. In addition, k≤1000,n≤50k≤1000,n≤50 and it is necessary to print swaps themselves. You can hack this problem if you solve it. But you can hack the previou…
题意:给定两个字符串,问是否存在交换方案使得两个字符串相同,方案为交换次数小于等于2n,且每次只交换s1与s2中的一个字符 题解:考虑从前往后枚举,当第i位不同时,考虑找后边的第j位,若存在这样的第j位,则存在方案 1.存在aj==ai且j>i,那么交换aj,bi 2.存在bj==ai且j>i,那么先交换aj,bj,在交换aj,bi 这样对于每个位置最多两次操作,故若存在方案则一定在2n次内交换完成 #include<iostream> #include<cstdio>…
链接: http://codeforces.com/contest/1243/problem/B2 题目大意: 两个字符串,判断能否通过交换为从而使得这两个字符串完全一致,如不可以的话,直接输出NO,可以的话输出YES,并且输出每一步的交换位置. 思路:如果没个字符出现的次数为偶数次的话,那么一定可以成功,否则的话一定是NO. 如果说S[i]!=T[i],假如说,S中有与T[i]相同的元素,那么直接交换就可以了,操作次数为1,在T中找S[i]操作相同. S中没有与T[i]相同的元素,我们保证了每…
传送门 •前置知识-multimap的用法 $multimap$ 与 $map$ 的区别在于一个 $key$ 可以对应几个值: 对于 $map$ 而言,一个 $key$ 只能对应一个值,并且按照 $key$ 升序排列: 而 $multimap$ 的一个 $key$ 可以对应多个值,并且按照 $key$ 升序排列: 但是,相同的 $key$ 对应的多个值按照插入的顺序排列,不会自动排序: 定义:$multimap<char ,int >f$ 插值 $f.insert(make\_pair('a'…
D1. RGB Substring (easy version) time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output The only difference between easy and hard versions is the size of the input. You are given a string s consistin…
3868 - Earthstone: Easy Version Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3867 Description Earthstone is a famous online card game created by Lizard Entertainment. It is a collectible card g…