B. Sereja and Mirroring
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a2x × y matrix c which has the following properties:

  • the upper half of matrix c (rows with numbers from 1 to x) exactly matches b;
  • the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1).

Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several(possibly zero) mirrorings. What minimum number of rows can such matrix contain?

Input

The first line contains two integers, n and m (1 ≤ n, m ≤ 100). Each of the next n lines contains m integers — the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≤ aij ≤ 1) — the i-th row of the matrix a.

Output

In the single line, print the answer to the problem — the minimum number of rows of matrix b.

Sample test(s)
input
4 3
0 0 1
1 1 0
1 1 0
0 0 1

output
2

input
3 3
0 0 0
0 0 0
0 0 0

output
3

input
8 1
0
1
1
0
0
1
1
0

output
2

Note

In the first test sample the answer is a 2 × 3 matrix b:

001
110

If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:

001
110
110
001
#include <stdio.h>
#include <stdlib.h>
#include <string.h>int num[111][111];int main ()
{int n,m;scanf ("%d%d",&n,&m);int i,k;for (i = 0;i < n;i++)for (k = 0;k < m;k++)scanf ("%d",&num[i][k]);int ans = n;aif (n % 2)printf ("%d\n",n);else{int tn = n;while (1){int tf = 1;for (i = 0;i < tn / 2;i++)for (k = 0;k < m;k++)if (num[i][k] != num[tn - 1 - i][k])tf = 0;if (tf){if (tn % 2)break;tn /= 2;}else{//tn *= 2;break;}}printf ("%d\n",tn);}return 0;
}

B. Sereja and Mirroring相关推荐

  1. Codeforces Sereja and Mirroring

    Description Let's assume that we are given a matrix b of size x × y, let's determine the operation o ...

  2. Codeforces Round #243 (Div. 2) Problem B - Sereja and Mirroring 解读

    http://codeforces.com/contest/426/problem/B 对称标题的意思大概是.应当指出的,当线数为奇数时,答案是线路本身的数 #include<iostream& ...

  3. Codeforces Round #243 (Div. 2) A~C

    题目链接 A. Sereja and Mugs time limit per test:1 second memory limit per test:256 megabytes input:stand ...

  4. 炫 音乐可视化 html5 在线,HTML5打造的炫酷本地音乐播放器-喵喵Player

    将之前捣腾的音乐频谱效果加上一个播放列表就成了现在的喵喵播放器(Meow meow Player,额知道这名字很二很装萌~),全HTML5打造的网页程序,可本地运行也可以挂服务器上用. 在线Demo及 ...

  5. Codeforces 题目合集+分类+代码 【Updating...】【361 in total】

    961A - Tetris                                                模拟                                      ...

  6. SQL Server HA - 数据库镜像2 (Mirroring)(1418错误解决)

    SQL Server2008数据库镜像的配置 (1418错误解决) 准备三台安装SQL的服务器,三台中两台担当惊喜数据库,一天当作监控服务器 在要做镜像的数据库之上右键单击,选择备份 备份类型为完整, ...

  7. iOS Airplay Screen Mirroring 同屏技术详解

    投屏技术已经被大量用在身边的产品,比如电视投屏,投影仪,视频会议产品中. 在iOS平台外的其他平台中都已经有非常成熟的标准和实现.但在封闭的苹果iOS和Mac系统中,苹果使用私有的Airplay协议进 ...

  8. Sereja and Brackets CodeForces - 380C (树状数组+离线)

    Sereja and Brackets 题目链接: CodeForces - 380C Sereja has a bracket sequence s1, s2, ..., *s**n, or, in ...

  9. Sereja and Brackets CodeForces - 380C (线段树+分治思路)

    Sereja and Brackets 题目链接: CodeForces - 380C Sereja has a bracket sequence s1, s2, ..., *s**n, or, in ...

最新文章

  1. Nature封面:脑机接口重大突破!意念手写字速度破纪录!
  2. 皮一皮:高科技产品真是防不胜防...
  3. 如何快速安全的插入千万条数据?
  4. java中的hashcode方法作用以及内存泄漏问题
  5. REST风格笔记【简介篇】
  6. 爬虫学习二: bs4 xpath re
  7. 51Nod-1101 换零钱【0/1背包+DP】
  8. 家庭上网用路由器和ADSL的连接
  9. HR-FICO跨系统工资过账的一些知识点分享
  10. 【Java后端】技术文档模板
  11. 基2时域采样快速傅里叶变换、反变换算法在python上的实现(自制轮子)
  12. cad图形不见了怎么办_画好的cad图纸文件不见了怎么找回?
  13. js之JSON格式用法和序列化JSON.stringify(value, replacer, space)以及反序列化JSON.parse(string)
  14. 疫苗接种 vaccine jab
  15. 酒水知识(六大基酒之白兰地_Brandy)
  16. 如何用Java设计一个简单的窗口界面(初级二)
  17. java自学 part2 数组 类和对象 包 继承 多态 抽象类 接口
  18. IDEA创建maven项目时的plugins、dependencies飘红问题
  19. 什么叫做石英表_石英表和机械表区别是什么?
  20. BlockingQueue

热门文章

  1. 回忆过去,痛苦的相思忘不了
  2. audiosever耗电_audio服务自动停止 - 卡饭网
  3. 使用腾讯云sms实现短信验证功能
  4. Unity 语音识别以及音频可视化
  5. 工厂模式 五种写法总结
  6. hp8080计算机无法usb启动,HP Compaq 8000 Elite 台式机​无法从U盘启动解决办法
  7. STM32CUBEMX开发GD32F303(16)----移植兆易创新SPI Nor Flash之GD25Q64Flash
  8. 利用MODIS TOOL批量重投影MODIS
  9. debian 安装打印机驱动及打印机共享
  10. 新年春节EDM邮件内容设计案例分享