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 ...
随机推荐
- BeanUtils使用将一个对象拷贝到另外一个对象
这里的BeanUtils是BeanUtils是org.springframework.beans.BeanUtils,和org.apache.commons.beanutils.BeanUtils是有 ...
- 二十五、JavaScript之查找字符串中的字符串indexOf和lastIndexOf的用法
一.代码如下 二.效果如下 <!DOCTYPE html> <html> <meta http-equiv="Content-Type" conten ...
- 无法启动APK安装也,报异常FileUriExposedException
无法打开APK安装页,报异常FileUriExposedException, https://juejin.im/entry/58e4643db123db15eb79a902
- P1012 数字分类
转跳点:
- EUI库 - 容器
eui.UILayer UILayer是Group的子类它只有一个功能,到放到场景上后,宽高永远和场景宽度一致 Group Group 是自动布局的容器基类.如果包含的子项内容太大需要滚动显示 ...
- pppd调试心得.md
描述 pppd是用于驱动3g模块的一种方式,其本质是和运营商APN协商,建立连接 其与运营商之间使用ppp协议,而用户在应用层使用系统提供的socket即可,从而忽略底层使用的时何种接口的设备,避免因 ...
- Win10电脑安装虚拟机
版权声明:本文为CSDN博主「MHades」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明.原文链接:https://blog.csdn.net/qq_42545 ...
- iOS内存管理布局及管理方案-理论篇
苹果设备备受欢迎的背后离不开iOS优秀的内存管理机制,那iOS的内存布局及管理方案是怎样的呢?我们一起研究下. 内存管理分为五大块 栈区(stack):线性结构,内存连续,系统自己管理内存,程序运行记 ...
- Tensorflow学习教程------非线性回归
自己搭建神经网络求解非线性回归系数 代码 #coding:utf-8 import tensorflow as tf import numpy as np import matplotlib.pypl ...
- SpringCloud学习之Feign 的使用(五)
Feign 是一个声明式的伪RPC的REST客户端,它用了基于接口的注解方式,很方便的客户端配置,刚开始使用时还不习惯,感觉是在客户端写服务端的代码,Spring Cloud 给 Feign 添加了 ...