题目本质:如果答案是i,那么从行和列两维都会满足:以i的倍数分块,矩阵值相同。

一种解决方法:

1.首先题目里说了要在n的约数里找orzorz……

2.块中需要一整排都相同。用“与前一排相同否?”来判定,而每块的第一排允许与上一排不同。复杂度还是n^2。

  1. rep(i, , n) {
  2. ec[i] = true;
  3. rep(j, , n) {
  4. if (Matrix[i][j] != Matrix[i - ][j]) {
  5. ec[i] = false;
  6. break;
  7. }
  8. }
  9. }

行和列都弄一遍以上代码。

  1. #pragma comment(linker, "/STACK:1024000000,1024000000")
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <cstdlib>
  5. #include <cmath>
  6. #include <ctime>
  7. #include <cctype>
  8. #include <climits>
  9. #include <iostream>
  10. #include <iomanip>
  11. #include <algorithm>
  12. #include <string>
  13. #include <sstream>
  14. #include <stack>
  15. #include <queue>
  16. #include <set>
  17. #include <map>
  18. #include <vector>
  19. #include <list>
  20. #include <fstream>
  21. #define ri readint()
  22. #define gc getchar()
  23. #define R(x) scanf("%d", &x)
  24. #define W(x) printf("%d\n", x)
  25. #define init(a, b) memset(a, b, sizeof(a))
  26. #define rep(i, a, b) for (int i = a; i <= b; i++)
  27. #define irep(i, a, b) for (int i = a; i >= b; i--)
  28. #define ls p << 1
  29. #define rs p << 1 | 1
  30. using namespace std;
  31.  
  32. typedef double db;
  33. typedef long long ll;
  34. typedef unsigned long long ull;
  35. typedef pair<int, int> P;
  36. const int inf = 0x3f3f3f3f;
  37. const ll INF = 1e18;
  38.  
  39. inline int readint() {
  40. int x = , s = , c = gc;
  41. while (c <= ) c = gc;
  42. if (c == '-') s = -, c = gc;
  43. for (; isdigit(c); c = gc)
  44. x = x * + c - ;
  45. return x * s;
  46. }
  47.  
  48. const int maxn = ;
  49. int n;
  50. string s;
  51. int Matrix[maxn][maxn];
  52. bool ec[maxn], er[maxn];
  53.  
  54. void Deal(int i, string s) {
  55. rep(ss, , s.length() - ) {
  56. int k = isdigit(s[ss]) ? s[ss] - '' : + s[ss] - 'A';
  57. rep(t, , ) {
  58. Matrix[i][(ss << ) + t + ] = k >> ( - t) & ;
  59. }
  60. }
  61. }
  62.  
  63. int solve() {
  64. rep(i, , n) {
  65. ec[i] = true;
  66. rep(j, , n) {
  67. if (Matrix[i][j] != Matrix[i - ][j]) {
  68. ec[i] = false;
  69. break;
  70. }
  71. }
  72. }
  73. rep(j, , n) {
  74. er[j] = true;
  75. rep(i, , n) {
  76. if (Matrix[i][j] != Matrix[i][j - ]) {
  77. er[j] = false;
  78. break;
  79. }
  80. }
  81. }
  82.  
  83. irep(i, n, ) {
  84. if (n % i) continue;
  85. bool flag = true;
  86. rep(j, , n) {
  87. if ((j - ) % i != && (not ec[j] || not er[j])) {
  88. flag = false;
  89. break;
  90. }
  91. }
  92. if (flag) return i;
  93. }
  94. }
  95.  
  96. int main() {
  97. ios_base::sync_with_stdio(false);
  98. cin.tie();
  99.  
  100. cin >> n;
  101. rep(i, , n) {
  102. cin >> s;
  103. Deal(i, s);
  104. }
  105.  
  106. cout << solve() << endl;
  107. return ;
  108. }

CF ECR59div2 D的更多相关文章

  1. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

  2. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  3. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

  4. ARC下OC对象和CF对象之间的桥接(bridge)

    在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...

  5. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  6. CF memsql Start[c]UP 2.0 A

    CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...

  7. CF memsql Start[c]UP 2.0 B

    CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...

  8. CF #376 (Div. 2) C. dfs

    1.CF #376 (Div. 2)    C. Socks       dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...

  9. CF #375 (Div. 2) D. bfs

    1.CF #375 (Div. 2)  D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...

随机推荐

  1. cygwin使用笔记

    1.在cygwin里访问Windows盘 cd /cygdrive/c cd c: 2.整合cygwin命令到Windows中 假设cygwin安装在d:/develop/cygwin,则将d:/de ...

  2. mac安装python3

    http://www.jianshu.com/p/51811fa24752 brew install python3 安装路径:/usr/local/Cellar 使用: 执行python3即可 配置 ...

  3. FFMPEG more samples than frame size (avcodec_encode_audio2) 的解决方案

    在实际的项目中,从音频设备采集到的音频的类型和编码器类型(aac ,amr)通常是不一致的. 那么我们首先需要做重采样的过程.利用swr_convert 重新采样. 这时候我们可能会遇到另外一个问题. ...

  4. html5--5-3 给直线添加样式

    html5--5-3 给直线添加样式 学习要点 strokeStyle属性:设置颜色.渐变或模式(本节课只涉及到颜色) lineWidth属性:--设置线宽 Canvas的路径方法 moveTo() ...

  5. SQL Server中数据类型对应C#中数据类型

    在SQL Server 2008中新建数据表的时候有33种数据类型可选,下面分别列举了这些类型对应的C#数据类型 //----------------------------------------- ...

  6. 上传图片 ajax input type="file" 兼容 ie chroem 火狐

    上传图片,转载请注明出处!!! 兼容 ie chroem 火狐 html: <div id="uploadForm"> <input id="file& ...

  7. 简单数位DP

    https://cn.vjudge.net/problem/HDU-4722 懒得写看,代码注释吧;主要存板子 #include <cstdio> #include <cstring ...

  8. Linux-打包和文件系统

    1 文件后缀 在Linux中后缀没有实际意义 2 打包文件 tar c 创建一个归档 v 查看过程 f 指定文件名 t 列出归档内容 x 从归档中解压出文件 C 改变到哪个目录 z gzip压缩 j ...

  9. Ubuntu16.04 + cuda9.0 + cudnn7.1.4 + tensorflow安装

    安装前的准备 UEFI 启动GPT分区 Win10和Ubuntu16.04双系统安装 ubuntu16.04 NVIDIA 驱动安装 ubuntu16.04 NVIDIA CUDA8.0 以及cuDN ...

  10. bzoj3456

    分治+ntt 设dp[i]表示i个点的图联通的方案数 那么考虑dp,利用容斥,总-不符合,枚举j=1->i-1,然后考虑不符合,那么考虑和1联通的连通块,剩下的不和1连通,那么dp[i]=2^t ...