比较水的模拟 思路:就是模拟题意 注意:把数组开大点,开始wa了几次就是这个原因 #include<iostream> #include<string> #include<cstdio> using namespace std; string a, b; ], t, n; bool flag1; int main(){ cin>>n; cin>>a>>b; , q=; while(q<n){ ; while(q<n&…
题意:给定两个字符串,每次可以交换相邻两个字符,给出任意一组交换次数小于1e4的方案使得a串成为b串,输出交换的次数与位置,无解输出-1 n<=50 思路:每次找到第一个不相同的字符,从后面找到一个相同的换上来 若找不到相同的则输出-1 #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<iostream> #include<algo…
下面的代码来自c++ primer plus第5版第12章,书中代码写的非常好: // string1.h -- fixed and augmented string class definition #include <iostream> using std::ostream; using std::istream; #ifndef STRING1_H_ #define STRING1_H_ class String { private: char * str; // pointer to…
Two people are playing a game with a string ss, consisting of lowercase latin letters. On a player's turn, he should choose two consecutive equal letters in the string and delete them. For example, if the string is equal to "xaax" than there is…
1813: good string Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 93  Solved: 15 SubmitStatusWeb Board Description 给定一个字符串,判断它是否是good string. good string定义为: ① 字符s是good string,字符p是good string,字符y也是good string ② P和Q都是good string,则PQ是good string ③ P是go…
CRB and String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 491    Accepted Submission(s): 186 Problem Description CRB has two strings s and t. In each step, CRB can select arbitrary charact…
题意:有两个字符串\(S\)和\(T\),判断\(T\)是否能由\(S\)通过交换某位置的相邻字符得到,如果满足,输出交换次数及每次交换的位置,否则输出\(-1\). 题解:首先判断不满足的情况,只有当两个字符串中出现的字母次数不同时不满足条件,用桶判断一下即可.然后我们再来看有解的情况,我们对\(T\)的每个字符标上序号,如样例1中:\(abdfec\)对应\(123456\),则\(S\)中与之对应的是\(abcdef\)->\(126354\),所以要想让\(S\)变成\(T\),就要让其…
Description ​ "全"在十分愉快打工,第0天,给了他一个仅有小写字母构成的长度为N的字符串S0,在之后的第i天里,"全"的工作是将Si−1复制一份到一个新的字符串Si中,在接下来的描述中,我们用Si[j]表示串Si中的第j个字符 然而"全"十分不熟练,在复制的时候他容易出错.比如说在复制Si−1[j]到Si[j]的时候有时他会把Si[j]上的字符写成Si[j−1]Si[j−1],而不是本应被写上去的Si−1[j],更具体一点就是新串中…
Vasya has a string s of length n. He decides to make the following modification to the string: Pick an integer k, (1≤k≤n). For i from 1 to n−k+1, reverse the substring s[i:i+k−1] of s. For example, if string s is qwer and k=2, below is the series of…
/* * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package java.lang; import java.io.ObjectStreamClass;import java.io.ObjectStreamField;import java.…