Description

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 a 2x × 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 matrixa. 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 Input

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

Hint

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

题目意思:给你一个矩阵a,如果是严格对称的,必须是偶对称,就消去下半部分,问最后剩多少部分.

利用字符串,方便比较。

#include <iostream>
#include <stdio.h>
#include <cstdlib>
using namespace std;
int main()
{int n,m,flag;string s[101];char ch;while (cin>>n>>m){flag=0;for (int i=0; i<n; i++){for (int j=0; j<m; j++){cin>>ch;if(j==0){s[i]=ch;}else{s[i]+=ch;}}}if(n%2){cout<<n<<endl;}else{while (!(n%2)){int i;for (i=0; i<n/2; i++){if(s[i]!=s[n-i-1]){break;}}if(i==n/2){n/=2;}else{cout<<n<<endl;flag=1;break;}}if(!flag){cout<<n<<endl;}}}return 0;
}

Codeforces Sereja and Mirroring相关推荐

  1. B. Sereja and Mirroring

    B. Sereja and Mirroring time limit per test 1 second memory limit per test 256 megabytes input stand ...

  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. Codeforces 题目合集+分类+代码 【Updating...】【361 in total】

    961A - Tetris                                                模拟                                      ...

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

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

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

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

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

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

  8. Codeforces Round #215 (Div. 2) D. Sereja ans Anagrams

    http://codeforces.com/contest/368/problem/D 题意:有a.b两个数组,a数组有n个数,b数组有m个数,现在给出一个p,要你找出所有的位置q,使得位置q  q+ ...

  9. Codeforces Round #243 (Div. 1)——Sereja and Squares

    题目链接 题意: 给n个点,求能组成的正方形的个数. 四边均平行与坐标轴 大神的分析: 经典题 我们考虑每一种x坐标,显然仅仅有<= sqrt{N}个x坐标出现了> sqrt{N}次,我们 ...

最新文章

  1. 罹患各种癌晚期,无法救治
  2. Centos5.5下lvs+keepalived集群
  3. eclipse 项目 无法 rename
  4. my life-long goal
  5. 视频检索扫盲 (一)
  6. Hike on a Graph HDU - 1252(bfs)
  7. 电脑长时间睡眠会自动关机吗_长期对着电脑皮肤会变黑吗?经常对电脑如何保护皮肤?...
  8. 15. GD32F103C8T6入门教程-adc单通道轮训采集
  9. Druid : 慢SQL统计与监控
  10. Java8 Math新增方法
  11. 织梦怎样调取mysql_如何实现dedecms外部数据库调用
  12. Docker 踩坑之一:Error response from daemon: write *** : no space left on device
  13. java判断字符串不为空_Java判断字符串是否为空的方法
  14. 基于微信小程序点餐系统的设计与实现
  15. Open Inventor:Windows下编译安装Coin3D
  16. ZDNS宣布完成B轮融资,根服务器之外,顶级域名系统迎重要机遇
  17. 干货:8266在3d打印机上的使用
  18. 有一个XxY的网格,一个机器人只能走格点且只能向右或向下走,要从左上角走到右下角。请设计一个算法,计算机器人有多少种走法。 给定两个正整数int x,int y,请返回机器人的走法数目。保证x+y小
  19. 最网最全python框架--scrapy(体系学习,爬取全站校花图片),学完显著提高爬虫能力(附源代码),突破各种反爬
  20. 文本工具来查看、分析、统计,比较

热门文章

  1. 在家访问办公室电脑能实现吗?远程控制办公室电脑的软件推荐
  2. 通过接口获取数据登录
  3. 处理 Exception 的几种实践,被很多团队采纳!
  4. 计算机二级vfp是啥,二级计算机VFP是什么?
  5. flex 解析 html5,Flex布局详解
  6. unity游戏重新开始,退出,停止,继续按钮及打包发布
  7. FPGA原理和结构简介
  8. 制作esp32-cam拍照上传,微信小程序照片显示的监控小车
  9. ES6/ES7/ES8新特性汇总
  10. css5辅助线,苦练 CSS 基本功——图解辅助线的原理和画法