Submission #68501


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <bits/stdc++.h>
using namespace std;
int main() {
// n*nのポスターを扱う
int n;
cin >> n;
// 修正前後のポスターを格納する文字列配列(文字二次元配列)
string ps[ n + 10 ];
string af[ n + 10 ];
for (int i = 0; i < n; i++) {
// 修正前のポスターを読み込む
cin >> ps[ i ];
}
for (int i = 0; i < n; i++) {
// 修正後のポスターを読み込む
cin >> af[ i ];
}
// 問題文より↓
// JOI 君は今あるポスターに以下の
// いずれかの作業を繰り返し行うことで,新しいポスターを作ることにした.
// ^^^^^^^^^^^^^^^^^^^^^^^^^
// つまり、3つの作業内容の内、一つだけを選ぶということ。->全パターン調べればいい
// 3つの方法でそれぞれどれだけの時間がかかるか調べる
int pt[ 4 ] = {0};
pt[ 1 ] = 1;
pt[ 2 ] = 1;
pt[ 3 ] = 2;
// ポスターのます目一つ一つを見ていく
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
// パターン1:順に比較していって、違ったら塗り替える
if (af[ i ][ j ] != ps[ i ][ j ]) {
pt[ 0 ]++;
}
// パターン2:90度時計回りに回転させる
if (ps[ n - j - 1 ][ i ] != af[ i ][ j ]) {
pt[ 1 ]++;
}
// パターン3:90度反時計回りに回転させる
if (ps[ j ][ n - i - 1 ] != af[ i ][ j ]) {
pt[ 2 ]++;
}
// *** パターン4 *** :時計回り or 反時計回りを繰り返した結果、
// 180度回転した状態が出来上がる場合が存在する
if (ps[ n - i - 1 ][ n - j - 1 ] != af[ i ][ j ]) {
pt[ 3 ]++;
}
}
}
// それぞれの方法で掛かった時間の最小値を出力する
cout << *min_element(pt, pt + 4) << endl;
return (0);
}

ステータス

項目 データ
問題 1265 - ポスター (Poster)
ユーザー名 ei2030
投稿日時 2021-09-18 11:39:13
言語 C++17
状態 Accepted
得点 100
ソースコード長 1874 Byte
最大実行時間 47 ms
最大メモリ使用量 1628 KB

セット

セット 得点 Cases
1 ALL 100 / 100 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
01-01.txt AC 47 ms 1628 KB
1
01-02.txt AC 34 ms 1384 KB
1
01-03.txt AC 43 ms 1404 KB
1
01-04.txt AC 40 ms 1288 KB
1
01-05.txt AC 36 ms 1304 KB
1
01-06.txt AC 31 ms 932 KB
1
01-07.txt AC 26 ms 932 KB
1
01-08.txt AC 30 ms 948 KB
1
01-09.txt AC 39 ms 1348 KB
1
01-10.txt AC 35 ms 876 KB
1
01-11.txt AC 34 ms 1004 KB
1
01-12.txt AC 29 ms 1528 KB
1
01-13.txt AC 36 ms 924 KB
1
01-14.txt AC 30 ms 1452 KB
1
01-15.txt AC 37 ms 1100 KB
1
01-16.txt AC 18 ms 464 KB
1
01-17.txt AC 20 ms 564 KB
1
sample-01.txt AC 25 ms 404 KB
1
sample-02.txt AC 20 ms 508 KB
1
sample-03.txt AC 21 ms 484 KB
1