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

 #include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
const int INF=0x3f3f3f3f;
typedef long long LL;
const int mod=1e9+;
const double PI = acos(-);
#define Bug cout<<"---------------------"<<endl
const int maxn=1e4+;
using namespace std; int main()
{
#ifdef DEBUG
freopen("sample.txt","r",stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL); int n,m;
cin>>n>>m;
int ans=;
string str[];
set<string> st;
for(int i=;i<n;i++)
{
cin>>str[i];
st.insert(str[i]);
}
for(int i=;i<n;i++)
{
for(int j=i+;j<n;j++)
{
string s="";
for(int k=;k<m;k++)
{ if(str[i][k]!=str[j][k])
{
int t[]={};
if(str[i][k]=='S'||str[j][k]=='S') t[]=;
if(str[i][k]=='E'||str[j][k]=='E') t[]=;
if(str[i][k]=='T'||str[j][k]=='T') t[]=;
for(int p=;p<;p++)
{
if(!t[p])
{
if(p==) s+='S';
else if(p==) s+='E';
else s+='T';
}
}
}
else
s+=str[i][k];
}
if(st.count(s)) ans++;
}
}
cout<<ans/<<endl; return ;
}
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define pb push_back
#define all(v) (v.begin(),v.end())
#define mp make_pair string e[];
int n,K;
map<string,int>M; int main()
{
ios::sync_with_stdio(false);
int S='S'+'E'+'T';
long long ans=;
cin>>n>>K;
for(int i=;i<=n;++i)cin>>e[i],M[e[i]]++;
for(int i=;i<=n;++i){
for(int j=i+;j<=n;++j){
if(i==j)continue;
string T;
for(int o=;o<K;++o){
if(e[i][o]==e[j][o]) T+=e[i][o];
else{
T+=(char)(S-e[i][o]-e[j][o]);
}
}
ans+=M[T];
}
}cout<<ans/<<endl;
return ;
}

-

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. [LeetCode] 934. Shortest Bridge 最短的桥梁

    In a given 2D binary array A, there are two islands.  (An island is a 4-directionally connected grou ...

  2. mysql怎么查看当前登录用户

    mysql> select user();+----------------+| user()         |+----------------+| root@localhost |+--- ...

  3. 虚拟 DOM 到底是什么?

    虚拟 DOM 到底是什么? 作者:wangshengliang 注意:由于文章太长,对文章有删减,但是不会影响整体阅读 是什么? 虚拟 DOM (Virtual DOM )这个概念相信大家都不陌生,从 ...

  4. 第九届蓝桥杯省赛c/c++真题明码题解答案,另类excel解法思路

    直到快比赛才重视起之前学校给报了蓝桥杯,且这段时间一直在做Python,所以没做什么准备. 赛场上做这道题时连反码补码的知识点都记混,所以直接用了excel做这道题目,分享下做题思路.及题解. 标题: ...

  5. jedis哨兵模式的redis组(集群),连接池实现。(客户端分片)

    java 连接redis 我们都使用的 是jedis  ,对于redis这种频繁请求的场景我们一般需要对其池化避免重复创建,即创建一个连接池 ,打开jedis的 jar包我们发现,jedis对池已经有 ...

  6. (排序)P1068 分数线划定

    题解: 需要注意的是,快排完之后并不是按照编号从小到大的顺序输出 #include<iostream>using namespace std;int r=0;void swap(int & ...

  7. springboot+thymeleaf项目中使用th:replace访问templates子目录下的模板,会报错找不到模板路径

    解决方法: 先将模板路径放置templates目录下,发现可以访问,说明th:replace是可以用的. 那可能是出现在路径问题上面. 于是我开始调错,改路径. 后来在网上查找资料.说了很多种方法. ...

  8. 【shell】常用shell脚本

    1.检查主机存活状态 #!/bin/bash IP_LIST="192.168.18.1 192.168.1.1 192.168.18.2" for IP in $IP_LIST; ...

  9. 11 ~ express ~ 解决 cookie 中文报错的问题

    使用cookies包需要注意:1,cookie中是不能有中文的,一旦有中文,就会报错2,cookie是通过 中间件的形式直接挂载到 req对象上的,那么cookies有的方法,req.cookies就 ...

  10. 【分类问题中模型的性能度量(二)】超强整理,超详细解析,一文彻底搞懂ROC、AUC

    文章目录 1.背景 2.ROC曲线 2.1 ROC名称溯源(选看) 2.2 ROC曲线的绘制 3.AUC(Area Under ROC Curve) 3.1 AUC来历 3.2 AUC几何意义 3.3 ...