Submission #29048
ソースコード
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 | #include <bits/stdc++.h> using namespace std; //_____ typedef long long ll; typedef pair< int , int > Pii; typedef vector< int > Vi; typedef vector<Pii> Vp; #define pb push_back #define fi first #define se second #define mkp make_pair #define rep(i,n) for(int i=0; i<(n); ++i) #define reps(i,f,n) for(int i=(f); i<=(n); ++i) #define show(x) cerr << #x << ':' << x << endl #define outl(x) cout << (x) << '\n' #define INF (1 << 29) #define FAST() cin.tie(0), ios::sync_with_stdio(false) inline int chmax( int &a, int b){ return b>a ? a=b,1 : 0;} inline int chmin( int &a, int b){ return b<a ? a=b,1 : 0;} //_______ int H,W; char s[55][55]; char t[] = "WBR" ; int w[55], b[55], r[55]; main(){ FAST(); cin >> H >> W; rep(i,H){ rep(j,W){ cin >> s[i][j]; w[i] += s[i][j] != t[0]; b[i] += s[i][j] != t[1]; r[i] += s[i][j] != t[2]; } } int minv = INF; for ( int i=0; i<H-2; ++i){ for ( int j=i+1; j<H-1; ++j){ int c= 0, k=0; while (k <= i)c += w[k++]; while (k <= j)c += b[k++]; while (k < H) c += r[k++]; chmin( minv, c); } } outl(minv); } |
ステータス
項目 | データ |
---|---|
問題 | 0259 - ロシアの旗 (Russian Flag) |
ユーザー名 | Arumakan_ei1727 |
投稿日時 | 2017-11-24 18:47:56 |
言語 | C++11 |
状態 | Accepted |
得点 | 5 |
ソースコード長 | 1160 Byte |
最大実行時間 | 22 ms |
最大メモリ使用量 | 644 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 | 19 ms | 480 KB |
1
|
||||
2016-yo-t3-in2.txt | AC | 19 ms | 432 KB |
2
|
||||
2016-yo-t3-in3.txt | AC | 19 ms | 644 KB |
3
|
||||
2016-yo-t3-in4.txt | AC | 22 ms | 468 KB |
4
|
||||
2016-yo-t3-in5.txt | AC | 18 ms | 420 KB |
5
|
||||
2016-yo-t3-in_s1.txt | AC | 17 ms | 500 KB | |||||
2016-yo-t3-in_s2.txt | AC | 15 ms | 580 KB |