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 ...
随机推荐
- xargs详细
转自 http://czmmiao.iteye.com/blog/1949225 简介之所以能用到这个命令,关键是由于很多命令不支持|管道来传递参数,而日常工作中有有这个必要,所以就有了xargs命 ...
- Linux用户管理 权限管理 内存管理 网络管理命令 (第四天)
默认添加的用户会自动加入和用户名一样的组中su 切换用户查看当前登陆的用户: whoami id`查看当前用户属于哪个组:groupsgroupadd 组名 添加组groupdel 组名 删除组gre ...
- P 1025 链表反转
转跳点:
- POJ 1185:炮兵阵地
炮兵阵地 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 21366 Accepted: 8280 Description ...
- MVC学生管理系统-阶段V(模糊查询)
项目源码 :https://download.csdn.net/download/weixin_44718300/11091042 此处省略一段话.去上一篇查看 NO01:修改list.jsp < ...
- 虚拟机vmware vmnet8 未识别(转)
原文链接:https://blog.csdn.net/windows_q/article/details/50678646
- Floyd--P1119 灾后重建
题目背景 B地区在地震过后,所有村庄都造成了一定的损毁,而这场地震却没对公路造成什么影响.但是在村庄重建好之前,所有与未重建完成的村庄的公路均无法通车.换句话说,只有连接着两个重建完成的村庄的公路才能 ...
- swift中使用UIColllectionView实现横向轮播的一般方法
// // HomeLiveRankCell.swift // YYSwiftProject // // Created by Domo on 2018/7/28. // Copyright ...
- CSS属性之float浮动属性
float 属性定义元素在哪个方向浮动.以往这个属性总应用于图像,使文本围绕在图像周围,不过在 CSS 中,任何元素都可以浮动.浮动元素会生成一个块级框,而不论它本身是何种元素. float有四个属性 ...
- <kotlin>基础,杂七杂八(亲测有效)
okhttp class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) ...