B. Binary String Constructing

给定三个整数a、b和x,你需要构造一个长度为a+b的二进制字符串,其中包含恰好a个0,b个1,并且有x个位置i(1≤i<a+b),满足字符串s在这些位置上相邻字符不相同。题目保证存在答案。

B. Binary String Constructing

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given three integers aa, bb and xx. Your task is to construct a binary string ss of length n=a+bn=a+b such that there are exactly aa zeroes, exactly bb ones and exactly xx indices ii (where 1≤i<n1≤i<n) such that si≠si+1si≠si+1. It is guaranteed that the answer always exists.

For example, for the string "01010" there are four indices ii such that 1≤i<n1≤i<n and si≠si+1si≠si+1 (i=1,2,3,4i=1,2,3,4). For the string "111001" there are two such indices ii (i=3,5i=3,5).

Recall that binary string is a non-empty sequence of characters where each character is either 0 or 1.

Input

The first line of the input contains three integers aa, bb and xx (1≤a,b≤100,1≤x<a+b)1≤a,b≤100,1≤x<a+b).

Output

Print only one string ss, where ss is any binary string satisfying conditions described above. It is guaranteed that the answer always exists.

Examples

input

Copy

2 2 1

output

Copy

1100

input

Copy

3 3 3

output

Copy

101100

input

Copy

5 3 6

output

Copy

01010100

Note

All possible answers for the first example:

  • 1100;
  • 0011.

All possible answers for the second example:

  • 110100;
  • 101100;
  • 110010;
  • 100110;
  • 011001;
  • 001101;
  • 010011;
  • 001011

代码: 

#include <iostream>

using namespace std;

int main()
{
    int a,b,x;
    cin>>a>>b>>x;
    int flag;
    if(a>=b) flag=0;
    else flag=1;
    while(x!=1)
    {
        x--;
        if(flag){
            cout<<1;
            b--;
        }else{
            cout<<0;
            a--;
        }
        flag=1-flag;
    }
    if(flag==0){
        while(a!=0){
            cout<<0;
            a--;
        }
        while(b!=0)
        {
            cout<<1;
            b--;
        }
    }
    else{
        while(b!=0){
            cout<<1;
            b--;
        }
        while(a!=0){
            cout<<0;
            a--;
        }
    }
    cout<<endl;
    return 0;
}

 

unity报错: SerializationException: Unable to find assembly 'UnityEditor.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly () (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType (System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo assemblyInfo, System.String name) (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor (System.String objectName, System.String[] memberNames, System.Runtime.Serialization.Formatters.Binary.BinaryTypeEnum[] binaryTypeEnumA, System.Object[] typeInformationA, System.Int32[] memberAssemIds, System.Runtime.Serialization.Formatters.Binary.ObjectReader objectReader, System.Int32 objectId, System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo assemblyInfo, System.Runtime.Serialization.Formatters.Binary.SizedArray assemIdToAssemblyTable) (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Runtime.Serialization.Formatters.Binary.ObjectMap.Create (System.String name, System.String[] memberNames, System.Runtime.Serialization.Formatters.Binary.BinaryTypeEnum[] binaryTypeEnumA, System.Object[] typeInformationA, System.Int32[] memberAssemIds, System.Runtime.Serialization.Formatters.Binary.ObjectReader objectReader, System.Int32 objectId, System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo assemblyInfo, System.Runtime.Serialization.Formatters.Binary.SizedArray assemIdToAssemblyTable) (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped (System.Runtime.Serialization.Formatters.Binary.BinaryObjectWithMapTyped record) (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped (System.Runtime.Serialization.Formatters.Binary.BinaryHeaderEnum binaryHeaderEnum) (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run () (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize (System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Serialization.Formatters.Binary.__BinaryParser serParser, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck) (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream) (at <eae584ce26bc40229c1b1aa476bfa589>:0) UnityEditor.Scripting.APIUpdater.AssemblyDependencyGraph.LoadFrom (System.IO.Stream stream) (at <970e850b448646cc95471fb650b1c784>:0) UnityEditorInternal.APIUpdating.APIUpdaterManager.ReadOrCreateAssemblyDependencyGraph (System.String assemblyDependencyGraphFilePath) (at <970e850b448646cc95471fb650b1c784>:0) UnityEditorInternal.APIUpdating.APIUpdaterManager.UpdateDependencyGraph (System.Collections.Generic.IEnumerable`1[T] addedAssemblyPaths) (at <970e850b448646cc95471fb650b1c784>:0) UnityEditorInternal.APIUpdating.APIUpdaterManager.ProcessImportedAssemblies (System.String[] assemblies) (at <970e850b448646cc95471fb650b1c784>:0)
最新发布
06-26
在Unity中,当发生`SerializationException: Unable to find assembly 'UnityEditor.CoreModule, Version=0.0.0.0'`错误时,通常表明序列化系统在尝试加载特定程序集(如`UnityEditor.CoreModule`)时未能找到它。这种问题可能出现在项目升级、降级或包管理不一致的情况下。 ### 常见原因与解决方案 1. **Unity版本不兼容** 如果项目是从一个Unity版本迁移到另一个版本(例如从2021.x降到2019.x),某些程序集可能不再可用或路径发生了变化。这种情况会导致反序列化失败,因为旧数据依赖于已移除的类型或模块[^3]。 - 解决方案:确保使用的Unity版本与项目最初开发时的版本兼容。如果必须使用较旧版本,考虑重新导入所有自定义脚本和资源,并清理不必要的引用。 2. **Library文件夹缓存残留** Unity的`Library`文件夹存储了项目的序列化数据、资源数据库以及程序集缓存。如果此目录下存在过期或损坏的数据,可能导致无法正确加载类型或程序集。 - 解决方案:关闭Unity编辑器,删除整个`Library`文件夹(包括其子目录),然后重新打开项目以强制Unity重建该目录。 3. **缺少必要的程序集引用** 某些自定义类或脚本可能依赖于`UnityEditor.CoreModule`等内部模块进行序列化。如果这些模块未被正确加载或引用,会引发异常。 - 解决方案:检查脚本是否使用了仅限编辑器环境的类(如`UnityEditor`命名空间下的类型)。如果是运行时需要的序列化对象,应避免使用仅适用于编辑器的类型。 4. **跨平台或多人协作导致的元数据不一致** 在团队协作或多平台开发中,不同机器上的Unity安装配置可能不一致,导致某些程序集缺失或版本不符。 - 解决方案:统一团队成员的Unity版本及安装组件,确保所有开发者使用相同的模块和依赖项。 5. **自定义序列化逻辑问题** 如果使用了自定义的二进制序列化机制(如`BinaryFormatter`),可能会遇到类型路径变更或程序集名称更改导致的反序列化失败。 - 解决方案:避免使用`BinaryFormatter`进行长期持久化存储,改用更稳定的格式如JSON或ScriptableObject。若必须使用二进制序列化,建议使用绑定重定向或自定义解析器处理类型迁移问题。 6. **第三方插件冲突** 某些第三方插件可能引入了对特定程序集的依赖,而这些依赖在目标环境中不可用。 - 解决方案:排查并更新相关插件至兼容当前Unity版本的版本,或联系插件作者获取支持。 --- ### 示例代码:使用AppDomain.AssemblyResolve事件解决动态加载问题 ```csharp using System; using UnityEngine; public class AssemblyResolver : MonoBehaviour { private void Awake() { AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; } private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { // 根据需求手动加载缺失的程序集 if (args.Name.Contains("UnityEditor.CoreModule")) { return typeof(UnityEditor.EditorWindow).Assembly; // 加载实际存在的程序集 } return null; } } ``` 此方法可用于临时缓解因程序集路径变化导致的加载失败问题,但不应作为长期解决方案。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值