CodeForces 1287B Hyperset



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的更多相关文章
- Codeforces Round #612 (Div. 2) 前四题题解
这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...
- Codeforces Round #612 (Div. 2)
https://codeforces.com/contest/1287/ A - Angry Students 题意:求A后面的P最长连续有几个? 题解:? int n; char s[200005] ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
随机推荐
- JPA#OneToOne
无力吐槽. 一对一,一个人有一个身份证号码.一个人有一条命,类似于这一种的就是一对一的关系. 涉及到的注解两个: OneToOne JoinColumn( name="当前实体对应数据库表中 ...
- PHP-文件目录操作
使用递归遍历指定文件目录及其子目录下的所有文件 思路: 1.打开目录: 2.遍历目录,判断是否还是目录.是目录则返回第1步,不是目录进入第三步: 3.把文件名显示出来 使用到的文件目录操作函数: ...
- Java中的日期表示类
一.概述 Java中的日期类设计的比较失败,刚开始使用Date来计算时间,后来大部分Date类的方法都过时了:想用Calendar类代替Date类,然而Calendar类也是不尽如人意.下面简单介绍下 ...
- Python MySQL Join
章节 Python MySQL 入门 Python MySQL 创建数据库 Python MySQL 创建表 Python MySQL 插入表 Python MySQL Select Python M ...
- hdu 3388 Coprime
第一个容斥的题,感觉这东西好神啊.于是扒了一发题解2333 首先想对于[1,x]内有多少与n,m都互质的数,显然x是存在单调性的,所以可以二分一下. 那么互质的数的求法,就是x-存在n,m一个质因数的 ...
- 2.10 Jetpack LiveData部分
LiveData是一个可观察的数据持有者类,但和其他的可观察对象不同,它与生命周期相关联,比如Activity的生命周期.LiveData能确保仅在Activity处于活动状态下才会更新.也就是说当观 ...
- [Python3] RSA的加解密和签名/验签实现 -- 使用pycrytodome
Crypto 包介绍: pycrypto,pycrytodome 和 crypto 是一个东西,crypto 在 python 上面的名字是 pycrypto 它是一个第三方库,但是已经停止更新,所以 ...
- 吴裕雄--天生自然 PHP开发学习:echo 和 print 语句
<?php echo "<h2>PHP 很有趣!</h2>"; echo "Hello world!<br>"; ec ...
- C# 互操作性入门系列(二):使用平台调用调用Win32 函数
好文章搬用工模式启动ing ..... { 文章中已经包含了原文链接 就不再次粘贴了 言明 改文章是一个系列,但只收录了2篇,原因是 够用了 } --------------------------- ...
- Python爬虫之解析网页
常用的类库为lxml, BeautifulSoup, re(正则) 以获取豆瓣电影正在热映的电影名为例,url='https://movie.douban.com/cinema/nowplaying/ ...