CodeForces 152C Pocket Book
Description
One day little Vasya found mom's pocket book. The book had n names of her friends and unusually enough, each name was exactly mletters long. Let's number the names from 1 to n in the order in which they are written.
As mom wasn't home, Vasya decided to play with names: he chose three integers i, j, k (1 ≤ i < j ≤ n, 1 ≤ k ≤ m), then he took names number i and j and swapped their prefixes of length k. For example, if we take names "CBDAD" and "AABRD" and swap their prefixes with the length of 3, the result will be names "AABAD" and "CBDRD".
You wonder how many different names Vasya can write instead of name number 1, if Vasya is allowed to perform any number of the described actions. As Vasya performs each action, he chooses numbers i, j, k independently from the previous moves and his choice is based entirely on his will. The sought number can be very large, so you should only find it modulo 1000000007(109 + 7).
Input
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of names and the length of each name, correspondingly. Then n lines contain names, each name consists of exactly m uppercase Latin letters.
Output
Print the single number — the number of different names that could end up in position number 1 in the pocket book after the applying the procedures described above. Print the number modulo 1000000007(109 + 7).
Sample Input
2 3
AAB
BAA
4
4 5
ABABA
BCGDG
AAAAA
YABSA
216
Hint
In the first sample Vasya can get the following names in the position number 1: "AAB", "AAA", "BAA" and "BAB".
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
int n,m;
int i,j,k;
char a[][];
int b[];
long long c[];
while(scanf("%d %d",&n,&m)!=EOF)
{
memset(c,,sizeof(c));
for(i=;i<=n;i++)
scanf("%s",a[i]);
for(i=;i<m;i++)
{
memset(b,,sizeof(b));
for(j=;j<=n;j++)
{
b[a[j][i]-'A']++;
}
for(j=;j<=;j++)
if(b[j])
c[i]++;
//printf("%I64d\n",c[i]);
}
long long ans=c[];
for(i=;i<m;i++)
ans=ans*(c[i]%)%;
printf("%I64d\n",ans);
}
return ;
}
CodeForces 152C Pocket Book的更多相关文章
- Codeforces 152C:Pocket Book(思维)
http://codeforces.com/problemset/problem/152/C 题意:给出n条长度为m的字符串,对于第一条字符串的每个位置利用第2~n条字符串的相应位置的字符去替换相应的 ...
- 2021.5.22 vj补题
A - Marks CodeForces - 152A 题意:给出一个学生人数n,每个学生的m个学科成绩(成绩从1到9)没有空格排列给出.在每科中都有成绩最好的人或者并列,求出最好成绩的人数 思路:求 ...
- 组合数学题 Codeforces Round #108 (Div. 2) C. Pocket Book
题目传送门 /* 题意:每一次任选i,j行字符串进行任意长度前缀交换,然后不断重复这个过程,问在过程中,第一行字符串不同的个数 组合数学题:每一列不同的字母都有可能到第一行,所以每列的可能值相乘取模就 ...
- Codeforces Round #108 (Div. 2)
Codeforces Round #108 (Div. 2) C. Pocket Book 题意 给定\(N(N \le 100)\)个字符串,每个字符串长为\(M(M \le 100)\). 每次选 ...
- codeforces Gym 100187B B. A Lot of Joy
B. A Lot of Joy Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/proble ...
- Codeforces 789A Anastasia and pebbles(数学,思维题)
A. Anastasia and pebbles time limit per test:1 second memory limit per test:256 megabytes input:stan ...
- Codeforces Codeforces Round #484 (Div. 2) E. Billiard
Codeforces Codeforces Round #484 (Div. 2) E. Billiard 题目连接: http://codeforces.com/contest/982/proble ...
- 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 ...
随机推荐
- 夺命雷公狗ThinkPHP项目之----企业网站28之网站前台左侧导航的实现
我们基于刚才在model层的找顶级分类的代码在进行修改即可: <?php namespace Home\Controller; use Think\Controller; class Commo ...
- sqlhelper-sql数据库
using System; using System.Collections.Generic; using System.Text; using System.Data.SqlClient; usin ...
- 【sinatra】修改默认ip绑定
加入 # 默认的bind是127.0.0.1 set :bind, '0.0.0.0' #0.0.0.0之后你能通过lan访问这个服务器
- android 项目学习随笔三(Fragment )
1.在主页面(activity引用Fragment )的布局文件中定义FrameLayout ,加载Fragment <FrameLayout xmlns:android="http ...
- struts2 笔记03 异常支持、防止页面刷新和后退、方法验证
Struts2对异常支持(声明式异常.自动的异常处理), 异常处理(运行期异常事务自动回滚) 1. 自定义异常类,继承RuntimeException或Exception实现构造方法. 2. 配置异常 ...
- hadoop之Spark强有力竞争者Flink,Spark与Flink:对比与分析
hadoop之Spark强有力竞争者Flink,Spark与Flink:对比与分析 Spark是一种快速.通用的计算集群系统,Spark提出的最主要抽象概念是弹性分布式数据集(RDD),它是一个元素集 ...
- linux man
man能够为除命令之外的配置文件.系统调用.库调用等都能提供帮助手册,他们分别位于不同的章节中: 1.用户命令 2.系统调用 3.库调用 4.设备文件 5.配置文件 6.游戏 7.杂项 8.管理命令
- jQuery_Ajax_Json 异步接收PHP端传来的json数据
[json]{"user_id":"1172940","rmb_point":"0","weixin_id&q ...
- [HTML]HTML5实现可编辑表格
HTML5实现的简单的可编辑表格 [HTML]代码 <!DOCTYPE html > <html > <head> <meta charset="u ...
- 转 python range 用法
详细记录python的range()函数用法 使用python的人都知道range()函数很方便,今天再用到他的时候发现了很多以前看到过但是忘记的细节.这里记录一下range(),复习下list的 ...