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 ...
随机推荐
- python 定义一个空集合、空字典
s = set() #定义一个空集合 s = {} #定义一个空字典
- Flask—路由的注册方法
第一种注册方法 from flask import Flask app = Flask(__name__) @app.route("/hello") # 第一种注册方法 def h ...
- 三十、SAP中的内置图标
一.选择[编辑]->[模式] 二.选中写入模式 三.选中图标 四.选择我们需要的图标 五.选中图标后,选择复制 六.点击之后,会回到代码界面,如下 七.执行结果如下,显示出了一个神奇的图标
- 119-PHP调用private成员的方法
<?php class ren{ //定义人类 private $birthday='1990-12-20'; //定义private修饰的成员属性 public function say_bi ...
- 3.3. Mapping methods with several source parameters(具有多个源参数的映射方法)
3.3. Mapping methods with several source parameters(具有多个源参数的映射方法) MapStruct 还支持具有多个源参数的映射方法.这是比较实用的, ...
- 吴裕雄--天生自然C++语言学习笔记:C++ 模板
模板是泛型编程的基础,泛型编程即以一种独立于任何特定类型的方式编写代码. 模板是创建泛型类或函数的蓝图或公式.库容器,比如迭代器和算法,都是泛型编程的例子,它们都使用了模板的概念. 每个容器都有一个单 ...
- XSS跨站脚本攻击与CSRF跨站请求伪造攻击的学习总结(转载)
转载自 https://blog.csdn.net/baidu_24024601/article/details/51957270 之前就了解过这方面的知识,但是没有系统地总结.今天在这总结一下,也让 ...
- c++程序—输入
#include<iostream> using namespace std; #include<string> int main() { string str = " ...
- docker-compose 安装 mongodb
1. 修改 docker-compose.yml version: "2.1" services: php7.1: build: ./php image: php7.1-ext p ...
- nsq 从搭建到应用(更新ing)windows
1.官网下载地址 我安装的是windows nsq-1.2.0.windows-amd64.go1.12.9.tar.gz https://nsq.io/deployment/installing.h ...