zoukankan      html  css  js  c++  java
  • Codeforces C. Pattern 412 解决问题的方法

    这个问题是比较暴力的法律主体。

    主要是检查每一个是否没有使用足够的?。假设优先使用其他的无论是什么字母,假设你一定不能使用?。

    找一个有能力并给予所有的字符串匹配字符串,而且采用的最小?号码。

    原标题连接:http://codeforces.com/problemset/problem/412/C

    #include <stdio.h>
    #include <vector>
    #include <string>
    #include <iostream>
    using namespace std;
    
    int main()
    {
    	int N;
    	scanf("%d", &N);
    	vector<string> vst(N);
    	for (int i = 0; i < N; i++)
    	{
    		cin>>vst[i];
    	}
    	string ans;
    	for (int j = 0; j < (int)vst[0].size(); j++)
    	{
    		bool allX = true;
    		char x = vst[0][j];
    		for (int i = 1; i < (int)vst.size(); i++)
    		{
    			if (x == '?')
    			{
    				x = vst[i][j];
    			}
    			else if (vst[i][j] != '?' && vst[i][j] != x)
    			{
    				allX = false;
    				x = '?';
    				break;
    			}
    		}
    		if (allX && x == '?') ans.push_back('x');//全是?号
    		//else if (allX && x != '?') ans.push_back(x);//仅仅有一个不是?号
    		else ans.push_back(x);//超过一个不是?号,和上面情况合并了
    	}
    	cout<<ans;
    	return 0;
    }


    版权声明:笔者靖心脏。景空间地址:http://blog.csdn.net/kenden23/,只有经过作者同意转载。

  • 相关阅读:
    分布式事务
    事务
    shell 脚本编写
    使用fail2ban 防止ssh暴力破解
    数据加密
    英文字符串排序算法
    SpringCloud-ServerConfig 配置中心服务端 / 客户端
    maven setting参考配置
    java面向对象设计原则
    Java Object
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/4905358.html
Copyright © 2011-2022 走看看