Submission #45796


ソースコード

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
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << (x) << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;
int main() {
int n, m;
cin >> n >> m;
char flag[n][m];
REP(i, n) {
REP(j, m) {
scanf(" %c", &flag[i][j]);
}
}
int minv = INT_MAX;
int w[n + 1] = {}, b[n + 1] = {}, r[n + 1] = {};
FOR(i, 1, n + 1) {
w[i] = w[i - 1];
b[i] = b[i - 1];
r[i] = r[i - 1];
REP (j, m) {
if (flag[i - 1][j] != 'W') w[i]++;
if (flag[i - 1][j] != 'B') b[i]++;
if (flag[i - 1][j] != 'R') r[i]++;
}
}
FOR(i, 1, n - 1) {
FOR(j, i + 1, n) {
minv = min(minv, w[i] + b[j] - b[i] + r[n] - r[j]);
}
}
OUT(minv);
return 0;
}

ステータス

項目 データ
問題 0259 - ロシアの旗 (Russian Flag)
ユーザー名 Wonder /*ei1741*/
投稿日時 2018-12-12 17:05:27
言語 C++14
状態 Accepted
得点 5
ソースコード長 1183 Byte
最大実行時間 27 ms
最大メモリ使用量 604 KB

セット

セット 得点 Cases
1 INPUT1 1 / 1 *in1.txt
2 INPUT2 1 / 1 *in2.txt
3 INPUT3 1 / 1 *in3.txt
4 INPUT4 1 / 1 *in4.txt
5 INPUT5 1 / 1 *in5.txt

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
2016-yo-t3-in1.txt AC 25 ms 604 KB
1
2016-yo-t3-in2.txt AC 27 ms 444 KB
2
2016-yo-t3-in3.txt AC 20 ms 420 KB
3
2016-yo-t3-in4.txt AC 19 ms 520 KB
4
2016-yo-t3-in5.txt AC 20 ms 492 KB
5
2016-yo-t3-in_s1.txt AC 18 ms 336 KB
2016-yo-t3-in_s2.txt AC 27 ms 436 KB