N^2遍历所有得(i,j)然后可以根据(i,j)字符串构造出来第三个T字符串,然后查找一下是否有这个T存在即可,注意最后答案要/3因为会重复出现。

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <iostream>
  4. #include <string>
  5. #include <math.h>
  6. #include <algorithm>
  7. #include <vector>
  8. #include <stack>
  9. #include <queue>
  10. #include <set>
  11. #include <map>
  12. #include <sstream>
  13. const int INF=0x3f3f3f3f;
  14. typedef long long LL;
  15. const int mod=1e9+;
  16. const double PI = acos(-);
  17. #define Bug cout<<"---------------------"<<endl
  18. const int maxn=1e4+;
  19. using namespace std;
  20.  
  21. int main()
  22. {
  23. #ifdef DEBUG
  24. freopen("sample.txt","r",stdin);
  25. #endif
  26. ios_base::sync_with_stdio(false);
  27. cin.tie(NULL);
  28.  
  29. int n,m;
  30. cin>>n>>m;
  31. int ans=;
  32. string str[];
  33. set<string> st;
  34. for(int i=;i<n;i++)
  35. {
  36. cin>>str[i];
  37. st.insert(str[i]);
  38. }
  39. for(int i=;i<n;i++)
  40. {
  41. for(int j=i+;j<n;j++)
  42. {
  43. string s="";
  44. for(int k=;k<m;k++)
  45. {
  46.  
  47. if(str[i][k]!=str[j][k])
  48. {
  49. int t[]={};
  50. if(str[i][k]=='S'||str[j][k]=='S') t[]=;
  51. if(str[i][k]=='E'||str[j][k]=='E') t[]=;
  52. if(str[i][k]=='T'||str[j][k]=='T') t[]=;
  53. for(int p=;p<;p++)
  54. {
  55. if(!t[p])
  56. {
  57. if(p==) s+='S';
  58. else if(p==) s+='E';
  59. else s+='T';
  60. }
  61. }
  62. }
  63. else
  64. s+=str[i][k];
  65. }
  66. if(st.count(s)) ans++;
  67. }
  68. }
  69. cout<<ans/<<endl;
  70.  
  71. return ;
  72. }
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define LL long long
  4. #define inf 0x3f3f3f3f
  5. #define pii pair<int,int>
  6. #define pb push_back
  7. #define all(v) (v.begin(),v.end())
  8. #define mp make_pair
  9.  
  10. string e[];
  11. int n,K;
  12. map<string,int>M;
  13.  
  14. int main()
  15. {
  16. ios::sync_with_stdio(false);
  17. int S='S'+'E'+'T';
  18. long long ans=;
  19. cin>>n>>K;
  20. for(int i=;i<=n;++i)cin>>e[i],M[e[i]]++;
  21. for(int i=;i<=n;++i){
  22. for(int j=i+;j<=n;++j){
  23. if(i==j)continue;
  24. string T;
  25. for(int o=;o<K;++o){
  26. if(e[i][o]==e[j][o]) T+=e[i][o];
  27. else{
  28. T+=(char)(S-e[i][o]-e[j][o]);
  29. }
  30. }
  31. ans+=M[T];
  32. }
  33. }cout<<ans/<<endl;
  34. return ;
  35. }

-

CodeForces 1287B Hyperset的更多相关文章

  1. Codeforces Round #612 (Div. 2) 前四题题解

    这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...

  2. Codeforces Round #612 (Div. 2)

    https://codeforces.com/contest/1287/ A - Angry Students 题意:求A后面的P最长连续有几个? 题解:? int n; char s[200005] ...

  3. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  4. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  5. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  6. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  7. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  8. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  9. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

随机推荐

  1. BeanUtils使用将一个对象拷贝到另外一个对象

    这里的BeanUtils是BeanUtils是org.springframework.beans.BeanUtils,和org.apache.commons.beanutils.BeanUtils是有 ...

  2. 二十五、JavaScript之查找字符串中的字符串indexOf和lastIndexOf的用法

    一.代码如下 二.效果如下 <!DOCTYPE html> <html> <meta http-equiv="Content-Type" conten ...

  3. 无法启动APK安装也,报异常FileUriExposedException

    无法打开APK安装页,报异常FileUriExposedException, https://juejin.im/entry/58e4643db123db15eb79a902

  4. P1012 数字分类

    转跳点:

  5. EUI库 - 容器

      eui.UILayer UILayer是Group的子类它只有一个功能,到放到场景上后,宽高永远和场景宽度一致   Group Group 是自动布局的容器基类.如果包含的子项内容太大需要滚动显示 ...

  6. pppd调试心得.md

    描述 pppd是用于驱动3g模块的一种方式,其本质是和运营商APN协商,建立连接 其与运营商之间使用ppp协议,而用户在应用层使用系统提供的socket即可,从而忽略底层使用的时何种接口的设备,避免因 ...

  7. Win10电脑安装虚拟机

    版权声明:本文为CSDN博主「MHades」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明.原文链接:https://blog.csdn.net/qq_42545 ...

  8. iOS内存管理布局及管理方案-理论篇

    苹果设备备受欢迎的背后离不开iOS优秀的内存管理机制,那iOS的内存布局及管理方案是怎样的呢?我们一起研究下. 内存管理分为五大块 栈区(stack):线性结构,内存连续,系统自己管理内存,程序运行记 ...

  9. Tensorflow学习教程------非线性回归

    自己搭建神经网络求解非线性回归系数 代码 #coding:utf-8 import tensorflow as tf import numpy as np import matplotlib.pypl ...

  10. SpringCloud学习之Feign 的使用(五)

     Feign 是一个声明式的伪RPC的REST客户端,它用了基于接口的注解方式,很方便的客户端配置,刚开始使用时还不习惯,感觉是在客户端写服务端的代码,Spring Cloud 给 Feign 添加了 ...