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;a if (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 Round #243 (Div. 2) B. Sereja and Mirroring

    #include <iostream> #include <vector> #include <algorithm> using namespace std; in ...

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

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

  3. CF:Problem 426B - Sereja and Mirroring 二分或者分治

    这题解法怎么说呢,由于我是把行数逐步除以2暴力得到的答案,所以有点二分的意思,可是昨天琦神说是有点像分治的意思.反正总的来说:就是从大逐步细化找到最优答案. 可是昨晚傻B了.靠! 多写了点东西,然后就 ...

  4. codeforces B. Sereja and Mirroring 解题报告

    题目链接:http://codeforces.com/contest/426/problem/B 题目意思:给出一个n * m的矩阵a,需要找出一个最小的矩阵b,它能通过several次的mirror ...

  5. CodeForces - 426B(对称图形)

    Sereja and Mirroring Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64 ...

  6. Codeforces Round #243 (Div. 2) B(思维模拟题)

    http://codeforces.com/contest/426/problem/B B. Sereja and Mirroring time limit per test 1 second mem ...

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

    题目链接 A. Sereja and Mugs time limit per test:1 secondmemory limit per test:256 megabytesinput:standar ...

  8. CF380C. Sereja and Brackets[线段树 区间合并]

    C. Sereja and Brackets time limit per test 1 second memory limit per test 256 megabytes input standa ...

  9. T-SQL 语句创建Database的SQL mirroring关系

    1 证书部分:principle 和 secondary 端执行同样操作,更改相应name即可 USE master; --1.1 Create the database Master Key, if ...

随机推荐

  1. Handsontable 新增一行 默认值

    效果图:

  2. 使用Open Flash Chart(OFC)制作图表(Struts2处理)

    Java开源项目中制作图表比较出色的就是JFreeChart了,相信大家都听说过,它不仅可以做出非常漂亮的柱状图,饼状图,折线图基本图形之外,还能制作甘特图,仪表盘等图表.在Web应用中可以为项目增色 ...

  3. JavaScript(19)jQuery HTML 获取和设置内容和属性

    jQuery HTML jQuery 拥有可操作 HTML 元素和属性的强慷慨法. jQuery DOM 操作 jQuery 中非常重要的部分,就是操作 DOM 的能力.jQuery 提供一系列与 D ...

  4. linux中萌翻了的cowsay命令

    想要让你的linux萌翻吗? 首先需要安装cowsay软件 命令如下:sudo apt-get update;sudo apt-get install cowsay 然后对其输入命令,默认情况下,动物 ...

  5. baidu地图让多个标注出现在最佳视野

    原文:http://www.cnblogs.com/milkmap/archive/2011/08/23/2150641.html 摘要: “我有一堆标注,不规则的散落在地图的各个地方,我想把它们展示 ...

  6. 限制oracle用户创建、删除、修改用户对象

    在sys用户下执行: CREATE OR REPLACE TRIGGER lms2014BEFORE create or DROP OR ALTER ON databaseDECLAREBEGINIF ...

  7. XML 解析中,如何排除控制字符

    XML 解析中,如何排除控制字符 今天在解析一个中文的 XML时,始终报错 PCDATA invalid Char value 21 in Entity ,查询了一下这个 21 的ascii 值,发现 ...

  8. Unity-视图操作

    按下 F 键使画面的视角移动到被选中对象的正面 视图场景摄像机(14年的时候,这个操作弄的头晕--) 旋转:Alt(Command)+左键拖拽 平移:Alt+Ctrl(Command)+左键拖拽 旋转 ...

  9. easyui的combobox将得到的数据设定为下拉框默认值和复选框设定默认值

    通过easyui做了一个表,表里是从数据库拿到的数据. 现在双击某一行,通过点击行的id取到这一行的所有数据,现在需要修改这些得到的数据, 其中部分数据是<select>这个选择的, 问题 ...

  10. Kindeditor上传图片到七牛云存储插件(PHP版)

    由于工作需要,要使用第三方存储作为图床,发现七牛云挺不错,又可以免费使用10G的空间,决定先试试. 项目中使用的是Kindeditor作为网页编辑器的,七牛云的插件里没有现成的Kindeditor的插 ...