Submission #9039879


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
vector<string> rotateClockwise(vector<string> g) {
	int n = g.size();
	int m = g[0].size();
	vector<string> res(m, string(n, '#'));
	rep(i, 0, n) rep(j, 0, m) res[j][n - i - 1] = g[i][j];
	return res;
}
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int N;
string T[500];
int costs[4] = { 0, 1, 2, 1 };
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	vector<string> S(N);
	rep(y, 0, N) cin >> S[y];
	rep(y, 0, N) cin >> T[y];

	int ans = inf;
	rep(d, 0, 4) {
		int diff = 0;
		rep(y, 0, N) rep(x, 0, N) if (S[y][x] != T[y][x]) diff++;
		chmin(ans, diff + costs[d]);
		S = rotateClockwise(S);
	}
	cout << ans << endl;
}





Submission Info

Submission Time
Task A - ポスター (Poster)
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1966 Byte
Status
Exec Time 8 ms
Memory 1408 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt
All 100 / 100 sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
01-01.txt 8 ms 1408 KB
01-02.txt 8 ms 1408 KB
01-03.txt 8 ms 1408 KB
01-04.txt 8 ms 1408 KB
01-05.txt 8 ms 1408 KB
01-06.txt 7 ms 1280 KB
01-07.txt 7 ms 1208 KB
01-08.txt 7 ms 1208 KB
01-09.txt 7 ms 1280 KB
01-10.txt 7 ms 1280 KB
01-11.txt 7 ms 1216 KB
01-12.txt 7 ms 1280 KB
01-13.txt 7 ms 1152 KB
01-14.txt 7 ms 1280 KB
01-15.txt 7 ms 1192 KB
01-16.txt 1 ms 256 KB
01-17.txt 1 ms 256 KB
sample-01.txt 1 ms 256 KB
sample-02.txt 1 ms 256 KB
sample-03.txt 1 ms 256 KB