牛客提高D2t1 ACGT

分析

用map维护一下每种字符串当前有几个即可

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
map<string,int>mp;
string s,t;
int n,m,ans;
int main(){
    int i,j,k;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
      cin>>s;
      m=s.length();
      t=s;
      for(j=0;j<m;j++)
        if(s[j]=='A')t[j]='T';
          else if(s[j]=='C')t[j]='G';
          else if(s[j]=='G')t[j]='C';
          else t[j]='A';
      if(mp[t])ans++,mp[t]--;
        else mp[s]++;
    }
    cout<<ans<<"\n";
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/yzxverygood/p/11405700.html