A:hash 或者 map 或者trie。

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int maxn=200010;
map<vector<char>,int>mp;
char c[maxn][22];
vector<char>S;
int main()
{
    int N,M,ans=0;
    scanf("%d",&N);
    rep(i,1,N){
         scanf("%s",c[i]);
         if(c[i][0]=='T'||c[i][0]=='G'){
               int len=strlen(c[i]); S.clear();
               rep(j,0,len-1) S.push_back(c[i][j]);
               mp[S]++;
         }
    }
    rep(i,1,N) {
        if(c[i][0]=='A'||c[i][0]=='C') {
            int len=strlen(c[i]); S.clear();
            rep(j,0,len-1){
                if(c[i][j]=='A') S.push_back('T');
                if(c[i][j]=='T') S.push_back('A');
                if(c[i][j]=='C') S.push_back('G');
                if(c[i][j]=='G') S.push_back('C');
            }
            if(mp[S]>=1) ans++,mp[S]--;
        }
    }
    printf("%d\n",ans);
    return 0;
}
View Code

相关文章:

  • 2022-12-23
  • 2021-06-12
  • 2022-12-23
  • 2022-02-16
  • 2021-07-18
  • 2021-06-20
  • 2022-02-09
  • 2021-08-21
猜你喜欢
  • 2021-07-03
  • 2021-10-24
  • 2021-10-22
  • 2022-12-23
  • 2021-12-06
  • 2021-12-28
相关资源
相似解决方案