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. ubuntu12.04 安装完XRDP显示空白桌面

    先放链接:http://c-nergy.be/blog/?p=3518 在ubuntu软件中心搜索:fallback session,安装gnome-session-fallback: 在主文件夹(h ...

  2. GDI+应用2

    在上一篇里已经向大家介绍了如何使用GDI+绘制简单的图像,这一片继续向大家介绍其它一些绘图知识.1.首先我们来看下上一片中我们使用过的Pen.Pen的属性主要有: Color(颜色),DashCap( ...

  3. 实验吧-隐写术-刷新 刷新 快刷新(f5-steganography)

    题目:刷新 刷新 快刷新 其实这就算是很好的提示了,刷新的时候就是F5嘛,这个题就是F5隐写,用f5-steganography来解题. 题中的图片: f5-steganography下载链接:htt ...

  4. Inheritance and the prototype chain 继承和 原型 链

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain Inherita ...

  5. Apache使用mod_jk/mod_proxy模块实现代理、负载均衡的配置

    转载自:https://blog.csdn.net/yuanyuan_186/article/details/51290518 192.168.1.123/192.168.1.121为后端tomcat ...

  6. opencv3.0机器学习算法使用

    //随机树分类Ptr<StatModel> lpmlBtnClassify::buildRtreesClassifier(Mat data, Mat responses, int ntra ...

  7. Spring注解 @Autowired

    @Autowired可以对成员变量.方法和构造函数进行标注,来完成自动装配的工作,这里必须明确:@Autowired是根据类型进行自动装配的,如果需要按名称进行装配,则需要配合@Qualifier使用

  8. (简单模拟)P1540 机器翻译

    题解: #include<iostream>#include<cmath>using namespace std; int main(){ int m,n; cin>&g ...

  9. 尝试用kotlin做一个app(三)

    新闻列表 添加新闻列表可以使用RecyclerView.但是有个问题,RecyclerView只会在内部滚动,不会带动整个屏幕滚动.所以在原根布局外层添加androidx.core.widget.Ne ...

  10. 安装postgresql后找不到服务 postgresql service

    问题再现 环境: postgresql: 11.5 windows 10 企业版LTSC 64位 使用postgresql-11.5-1-windows-x64.exe安装后,让重新启动,但是重启后, ...