A. String Building

该博客讨论了Codeforces竞赛中的一个问题,问题要求判断给定字符串是否能由'aaaaaa', 'bbbbbb', 'aaaaaaaaa', 'bbbbbbbbb'这四个字符串拼接而成。关键在于分析字符串中'aaa'和'bbb'子串的连续性,如果存在某个位置两侧的字符均不同,则无法构造。提供的AC代码中,通过在字符串两端添加一个与结尾不同的字符,简化了边界条件的处理,然后检查每个位置是否满足构造条件。

https://codeforces.com/contest/1671/problem/A
在这里插入图片描述
input

8
aaaabbb
bbaaaaabbb
aaaaaa
abab
a
b
aaaab
bbaaa

output

YES
YES
YES
NO
NO
NO
NO
YES

题意
询问是否能通过使用 a a aa aa , b b bb bb , a a a aaa aaa , b b b bbb bbb 这四种字串拼凑来获得给定字符串

思路
其实相当于拆分成一个个连续 a a a 串和 b b b x ∗ 2 + y ∗ 3 > = 2 x * 2 + y * 3 >= 2 x2+y3>=2,其中 x x x y y y 至少一个大于 0 0 0,即只要出现的串中, a a a b b b 部分拆分开来的子长度必须大于 1 1 1 才能构造

所以我们只要判断一个位置上,如果两侧都与自身不相等则就是 N O NO NO

AC代码
对于第一个与最后一个位置上不想特判,则在string的两个尽头补一个与尽头不相等的字符即可

#include <bits/stdc++.h>
#define endl '\n'
#define AC return 0;
using namespace std;
//#define ll long long
//#define int long long


void slove()
{
    string s;
    cin >> s;
    int n = s.length();
    s = (s[0] == 'a' ? 'b' : 'a') + s + (s[n - 1] == 'a' ? 'b' : 'a');
    for(int i = 1; i <= n; i++)
        if(s[i] != s[i - 1] && s[i] != s[i + 1])
        {
            cout << "NO" << endl;
            return;
        }
    cout << "YES" << endl;
}

signed main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int T;cin >> T; while(T--)
    slove();
    AC
}
unity打包到Linux时出现DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files\Unity\Hub\Editor\2019.4.17f1c1\Editor\Data\PlaybackEngines\LinuxStandaloneSupport\Variations\linux64_withgfx_nondevelopment_mono'. System.IO.__Error.WinIOError (System.Int32 errorCode, System.String maybeFullPath) (at <9577ac7a62ef43179789031239ba8798>:0) System.IO.FileSystemEnumerableIterator`1[TSource].HandleError (System.Int32 hr, System.String path) (at <9577ac7a62ef43179789031239ba8798>:0) System.IO.FileSystemEnumerableIterator`1[TSource].CommonInit () (at <9577ac7a62ef43179789031239ba8798>:0) System.IO.FileSystemEnumerableIterator`1[TSource]..ctor (System.String path, System.String originalUserPath, System.String searchPattern, System.IO.SearchOption searchOption, System.IO.SearchResultHandler`1[TSource] resultHandler, System.Boolean checkHost) (at <9577ac7a62ef43179789031239ba8798>:0) System.IO.FileSystemEnumerableFactory.CreateFileNameIterator (System.String path, System.String originalUserPath, System.String searchPattern, System.Boolean includeFiles, System.Boolean includeDirs, System.IO.SearchOption searchOption, System.Boolean checkHost) (at <9577ac7a62ef43179789031239ba8798>:0) System.IO.Directory.InternalGetFileDirectoryNames (System.String path, System.String userPathOriginal, System.String searchPattern, System.Boolean includeFiles, System.Boolean includeDirs, System.IO.SearchOption searchOption, System.Boolean checkHost) (at <9577ac7a62ef43179789031239ba8798>:0) System.IO.Directory.InternalGetFiles (System.String path, System.String searchPattern, System.IO.SearchOption searchOption) (at <9577ac7a62ef43179789031239ba8798>:0) System.IO.Directory.GetFiles (System.String path) (at <9577ac7a62ef43179789031239ba8798>:0) UnityEditor.FileUtil.CopyDirectoryFiltered (System.String source, System.String target, System.Boolean overwrite, System.Func`2[T,TResult] includeCallback, System.Boolean recursive) (at <e9274028962b41d3817c3a283d24f8d0>:0) UnityEditor.LinuxStandalone.LinuxDesktopStandalonePostProcessor.CopyVariationFolderIntoStagingArea (UnityEditor.Modules.BuildPostProcessArgs args, System.Collections.Generic.HashSet`1[T] filesToNotOverwrite) (at /home/bokken/buildslave/unity/build/PlatformDependent/LinuxStandalone/Extensions/Managed/LinuxDesktopStandalonePostProcessor.cs:29) DesktopStandalonePostProcessor.SetupStagingArea (UnityEditor.Modules.BuildPostProcessArgs args, System.Collections.Generic.HashSet`1[T] filesToNotOverwrite) (at <e9274028962b41d3817c3a283d24f8d0>:0) DesktopStandalonePostProcessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at <e9274028962b41d3817c3a283d24f8d0>:0) Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown. DesktopStandalonePostProcessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at <e9274028962b41d3817c3a283d24f8d0>:0) UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <e9274028962b41d3817c3a283d24f8d0>:0) UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <e9274028962b41d3817c3a283d24f8d0>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
最新发布
06-26
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值