USACO 牛的基因学

题目来源:ACWING 每日一题;

翻译: 无敌的yxc

本题就是暴力枚举(遇事不决,暴力美学)


把每一个字符串输入代码所示

has数组存储有斑点牛,no存无斑点牛。(顾名思义)

然后用一个媒介数组hash(因为有哈希的原理所以叫hash了)

第一步找has中的基因序列,必须满足所有无斑点牛中某一个位置的所有基因都和有斑点牛的不相同(可以读题来理解
样例

3 8
AATCCCAT
GATTGCAA
GGTCGCAA//有斑点

ACTCCCAG
ACTCGCAT
ACTTCCAT//无斑点

例如:第一个位置(有斑点牛为:A G G,而无斑点为:A A A其中A重复出现了,所以第一个位置没有满足题意的基因)
然后再看第二个位置(有斑点牛为:A A G 而无斑点为:C C C,其中基因C为无斑点牛的特殊基因所以此时ans++;)
那么直接放代码;(看在我这么努力打字的份上点点赞吧(doge))

#include <iostream>
#include <string>
using namespace std;
const int N=110;
string has[N],no[N];
int n,m;
int ans;
int main()
{
   cin>>n>>m;
   for(int i=0;i<n;i++) cin>>has[i];
   for(int i=0;i<n;i++) cin>>no[i];
   for(int i=0;i<m;i++)
   {
       bool flag=false;

       int  hash[97]={};

       for(int j=0;j<n;j++) 
       hash[has[j][i]]++;

       for(int j=0;j<n;j++) 
       if(hash[no[j][i]]) 
       {flag=true;break;}

       if(!flag)
       ans++;
   }
   cout<<ans;
   return 0;
}
因为大写字符的ASII码最大才96所以我定义成了97

可以来我的acw博客瞅瞅

作者:孑孑
链接:AcWing 1776. 牛的基因组学 - AcWing
来源:AcWing
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

 

### USACO Competition Problem Solutions for Cow Games In the context of USACO competitions, problems involving cows often require a blend of algorithmic thinking and mathematical insight. For instance, one notable problem involves Farmer John providing hay to his cows on different days with varying quantities[^3]. This type of scenario can be modeled using dynamic programming or greedy algorithms depending on what is asked. For specific game-related challenges featuring cows within USACO contests, consider an example where cows play games that involve strategic decision-making under given constraints. These scenarios frequently test contestants' ability to apply concepts like graph theory, number manipulation, and optimization techniques effectively. A relevant exercise from similar competitive coding platforms includes dealing with round numbers which have properties making them interesting subjects for computational puzzles[^2]: ```python def count_round_numbers(n): binary_representation = bin(n)[2:] zero_count = binary_representation.count('0') return zero_count >= len(binary_representation) / 2 ``` This function checks whether a number has at least as many zeros as ones in its binary representation—a concept sometimes explored through playful contexts such as virtual cow activities designed around numerical patterns. To tackle these kinds of tasks successfully: - Understand all rules governing how elements interact. - Identify efficient ways to represent data structures involved. - Develop strategies based on observed trends or established theories applicable to the situation described.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

He_xj

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值