//暴力
#include <iostream>
#include <algorithm>
#include <string> using namespace std;
const int N = ;
string s1[N], s2[N], s3[N], s4[N];
int a[N][N], b[N][N]; int main()
{
int n;
cin >> n;
for (int i = ; i<n; i++)
cin >> s1[i];
cin.get();
for (int i = ; i<n; i++)
cin >> s2[i];
cin.get();
for (int i = ; i<n; i++)
cin >> s3[i];
cin.get();
for (int i = ; i<n; i++)
cin >> s4[i]; for (int i = ; i<n; i++)
for (int j = ; j < n; j++){
//只有两种方式
a[i][j] = (i + j) % == ? : ;
b[i][j] = (i + j) % ? : ;
}
for (int i = ; i<n; i++)
for (int j = ; j<n; j++)
a[i][j] += , b[i][j] += ; //比较
int ans = 1e9;
int f = ;
for (int i = ; i<n; i++)
for (int j = ; j<n; j++)
f += (s1[i][j] != a[i][j]) + (s2[i][j] != a[i][j]) + (s3[i][j] != b[i][j]) + (s4[i][j] != b[i][j]);
ans = min(ans, f);
f = ;
for (int i = ; i<n; i++)
for (int j = ; j<n; j++)
f += (s1[i][j] != a[i][j]) + (s2[i][j] != b[i][j]) + (s3[i][j] != a[i][j]) + (s4[i][j] != b[i][j]);
ans = min(ans, f);
f = ;
for (int i = ; i<n; i++)
for (int j = ; j<n; j++)
f += (s1[i][j] != a[i][j]) + (s2[i][j] != b[i][j]) + (s3[i][j] != b[i][j]) + (s4[i][j] != a[i][j]);
ans = min(ans, f);
f = ;
for (int i = ; i<n; i++)
for (int j = ; j<n; j++)
f += (s1[i][j] != b[i][j]) + (s2[i][j] != a[i][j]) + (s3[i][j] != a[i][j]) + (s4[i][j] != b[i][j]);
ans = min(ans, f);
f = ;
for (int i = ; i<n; i++)
for (int j = ; j<n; j++)
f += (s1[i][j] != b[i][j]) + (s2[i][j] != a[i][j]) + (s3[i][j] != b[i][j]) + (s4[i][j] != a[i][j]);
ans = min(ans, f);
f = ;
for (int i = ; i<n; i++)
for (int j = ; j<n; j++)
f += (s1[i][j] != b[i][j]) + (s2[i][j] != b[i][j]) + (s3[i][j] != a[i][j]) + (s4[i][j] != a[i][j]);
ans = min(ans, f);
cout<< ans <<endl;
system("pause");
return ;
}

C. Chessboard( Educational Codeforces Round 41 (Rated for Div. 2))的更多相关文章

  1. D. Pair Of Lines( Educational Codeforces Round 41 (Rated for Div. 2))

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

  2. B. Lecture Sleep( Educational Codeforces Round 41 (Rated for Div. 2))

    前缀后缀和搞一搞,然后枚举一下区间,找出最大值 #include <iostream> #include <algorithm> using namespace std; ; ...

  3. (模拟)关于进制的瞎搞---You Are Given a Decimal String...(Educational Codeforces Round 70 (Rated for Div. 2))

    题目链接:https://codeforc.es/contest/1202/problem/B 题意: 给你一串数,问你插入最少多少数可以使x-y型机器(每次+x或+y的机器,机器每次只取最低位--% ...

  4. Educational Codeforces Round 41 (Rated for Div. 2)(A~D)

    由于之前打过了这场比赛的E题,而后面两道题太难,所以就手速半个多小时A了前4题. 就当练手速吧,不过今天除了C题数组开小了以外都是1A A Tetris 题意的抽象解释可以在Luogu里看一下(话说现 ...

  5. Multidimensional Queries(二进制枚举+线段树+Educational Codeforces Round 56 (Rated for Div. 2))

    题目链接: https://codeforces.com/contest/1093/problem/G 题目: 题意: 在k维空间中有n个点,每次给你两种操作,一种是将某一个点的坐标改为另一个坐标,一 ...

  6. Educational Codeforces Round 41 (Rated for Div. 2) ABCDEF

    最近打的比较少...就只有这么点题解了. A. Tetris time limit per test 1 second memory limit per test 256 megabytes inpu ...

  7. Educational Codeforces Round 41 (Rated for Div. 2)

    这场没打又亏疯了!!! A - Tetris : 类似俄罗斯方块,模拟一下就好啦. #include<bits/stdc++.h> #define fi first #define se ...

  8. Educational Codeforces Round 41 (Rated for Div. 2) D. Pair Of Lines (几何,随机)

    D. Pair Of Lines time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  9. Educational Codeforces Round 78 (Rated for Div. 2)E(构造,DFS)

    DFS,把和当前结点相连的点全都括在当前结点左右区间里,它们的左端点依次++,然后对这些结点进行DFS,优先对左端点更大的进行DFS,这样它右端点会先括起来,和它同层的结点(后DFS的那些)的区间会把 ...

随机推荐

  1. meteor---在合并打包多个文件ZIP下载的功能

    实现多个文件边打包边下载的功能,速度还可以,本人亲测,欢迎大家来指点archiver --用NPM安装这个模块---本人文件存储在file-collection 中,可以用fs : fs.create ...

  2. 【智能无线小车系列九】在树莓派上使用USB摄像头

    材料准备: 1.树莓派 2.AS 4WD小车 3.WebCam 4.小米移动电源 5.TP—LINK 高增益150MUSB无线网卡 操作流程: 1.将WebCam插上树莓派后,首先要确认树莓派是否支持 ...

  3. LightOJ1259 Goldbach`s Conjecture —— 素数表

    题目链接:https://vjudge.net/problem/LightOJ-1259 1259 - Goldbach`s Conjecture    PDF (English) Statistic ...

  4. BZOJ 2002 Bounce 弹飞绵羊 —— 分块算法

    题目链接:https://vjudge.net/problem/HYSBZ-2002 2002: [Hnoi2010]Bounce 弹飞绵羊 Time Limit: 10 Sec  Memory Li ...

  5. centos 7 / 6 smokeping安装

    官网 值得拥有:http://oss.oetiker.ch/smokeping/doc/reading.en.html 安装依赖包 1 2 yum -y install perl perl-Net-T ...

  6. android实现文字渐变效果和歌词进度的效果

    要用TextView使用渐变色,那我们就必须要了解LinearGradient(线性渐变)的用法. LinearGradient的参数解释 LinearGradient也称作线性渲染,LinearGr ...

  7. codeforces 466A. Cheap Travel 解题报告

    题目链接:http://codeforces.com/problemset/problem/466/A 题目意思:一个 ride 需要 a 卢布,m 个 ride 需要 b 卢布,这两种方案都可以无限 ...

  8. C++中对类的提前引用声明注意事项

    //或许,友元是VC++6.0心里永远的痛,对于这个BUG我一直很介意.//注:这个程序在VC++6.0里是行不通的,在VS2008里是可以的.#include <iostream> #i ...

  9. Linux-内存进程和软件安装

    1 swap分区 swapon -s 查看swap分区 mkswap 某分区挂载点 swapon -a 分区 激活该swap swapoff 挂载点 取消swap分区 2 内存 free 查看内存空间 ...

  10. Python: PS 滤镜--旋转模糊

    本文用 Python 实现 PS 滤镜中的旋转模糊,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/details/392 ...