Submission #41909
ソースコード
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 66 67 68 69 70 71 72 73 74 75 76 77 | #include <iostream> #include <string> #include <stack> #include <queue> #include <cstring> #include <algorithm> #include <vector> //#include <cstdio> #include <cmath> #include <cstdlib> #include <functional> #include <map> #include <numeric> using namespace std; #define elif else if #define echo cout << #define read cin >> #define fin << '\n' #define finn cout << '\n' #define forin(i, n) for ( int i = 0; i < n; i++ ) #define unless(flg) if(!(flg)) #define zu >> #define und << #define alles(obj) obj.begin(), obj.end() #define bash push_back #define makePair make_pair // type-define #define String string #define Stack stack #define Queue queue #define pQueue priority_queue #define Vector vector #define Pair pair #define Map map typedef long long llong; typedef bool boolean; typedef Pair< int , int > Pii; typedef Vector< int > Vi; // utils const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}; const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1}; boolean isMovable( int x, int y, int w, int h){ return (x>=0&&y>=0&&x<w&&y<h);}; const int INF = 1 << 29; char mas[64][64]; int w[64], b[64], r[64]; int minv = INF; signed main(){ cin.tie(0); ios::sync_with_stdio( false ); int n, m; read n >> m; for ( int i = 0; i < n; i++ ) { read mas[i]; } for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < m; j++ ) { if ( mas[i][j] == 'W' ) w[i]++; elif ( mas[i][j] == 'B' ) b[i]++; else r[i]++; } } for ( int i = 0; i < n-2; i++ ) { for ( int j = i+1; j < n-1; j++ ) { int tmp = 0; for ( int k = 0; k <= i; k++ ) tmp += m-w[k]; for ( int k = i+1; k <= j; k++ ) tmp += m-b[k]; for ( int k = j+1; k <= n-1; k++ ) tmp += m-r[k]; minv = min(minv, tmp); } } echo minv fin; return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0259 - ロシアの旗 (Russian Flag) |
ユーザー名 | r1825 |
投稿日時 | 2018-08-26 10:16:56 |
言語 | C++14 |
状態 | Accepted |
得点 | 5 |
ソースコード長 | 1911 Byte |
最大実行時間 | 38 ms |
最大メモリ使用量 | 692 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 | 38 ms | 480 KB |
1
|
||||
2016-yo-t3-in2.txt | AC | 22 ms | 440 KB |
2
|
||||
2016-yo-t3-in3.txt | AC | 21 ms | 532 KB |
3
|
||||
2016-yo-t3-in4.txt | AC | 18 ms | 612 KB |
4
|
||||
2016-yo-t3-in5.txt | AC | 21 ms | 692 KB |
5
|
||||
2016-yo-t3-in_s1.txt | AC | 24 ms | 648 KB | |||||
2016-yo-t3-in_s2.txt | AC | 17 ms | 612 KB |