結果

問題 No.421 しろくろチョコレート
ユーザー maimai
提出日時 2016-09-09 23:43:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,663 bytes
コンパイル時間 1,682 ms
コンパイル使用メモリ 169,384 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 05:59:05
合計ジャッジ時間 3,294 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 2 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 3 ms
5,376 KB
testcase_30 AC 3 ms
5,376 KB
testcase_31 AC 8 ms
5,376 KB
testcase_32 AC 3 ms
5,376 KB
testcase_33 AC 3 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 2 ms
5,376 KB
testcase_40 WA -
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 WA -
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 5 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
testcase_50 AC 2 ms
5,376 KB
testcase_51 WA -
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 2 ms
5,376 KB
testcase_55 AC 2 ms
5,376 KB
testcase_56 AC 2 ms
5,376 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 AC 2 ms
5,376 KB
testcase_63 AC 2 ms
5,376 KB
testcase_64 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//
// 気合で
// 

#include<bits/stdc++.h>

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007

#define TIME chrono::system_clock::now
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

int height,width;

char data[100][100];

int main(){
    int i,j,k;
    int x,y;
    
    cin>>height>>width;

    for (i=1;i<=height;i++){
        cin >> &data[i][1];
    }
    
    for (y=0;y<=height+1;y++)
        for (x=0;x<=width+1;x++)
            if (data[y][x]!='w' && data[y][x]!='b')
                data[y][x]='.';
                
    // debugaa(data,height+2,width+2)
    
    int score = 0;
    
    int flg=1;
    while(flg){
        flg=0;
        for (y=1;y<=height;y++){
            for (x=1;x<=width;x++){
                if (data[y][x]=='.') continue;
                k=(data[y-1][x]!='.')+(data[y+1][x]!='.')+(data[y][x-1]!='.')+(data[y][x+1]!='.');
                if (k==1){
                    flg=1;
                    score+=100;
                    data[y][x]='.';
                    data[y-1][x]=data[y+1][x]=data[y][x-1]=data[y][x+1]='.';
                }else if (!flg && 1<k){
                    flg=2;
                }
            }
        }
        if (flg==2){//長方形を茄子
            
            for (y=1;y<=height;y++){
                for (x=1;x<=width;x++){
                    if (data[y][x]=='.') continue;
                    k=(data[y-1][x]!='.')+(data[y+1][x]!='.')+(data[y][x-1]!='.')+(data[y][x+1]!='.');
                    if (k==2){
                        score+=100;
                        data[y][x]='.';
                        if (data[y-1][x]!='.'){
                            data[y-1][x]='.';
                            goto l_br_ra;
                        }
                        if (data[y+1][x]!='.'){
                            data[y+1][x]='.';
                            goto l_br_ra;
                        }
                        if (data[y][x-1]!='.'){
                            data[y][x-1]='.';
                            goto l_br_ra;
                        }
                        if (data[y][x+1]!='.'){
                            data[y][x+1]='.';
                            goto l_br_ra;
                        }
                    }
                }
            }
            l_br_ra:;
        }
    }
    // debugaa(data,height+2,width+2);
    
    int count_b=0,count_w=0;
    // cleanup
    for (y=1;y<=height;y++){
        for (x=1;x<=width;x++){
            if (data[y][x]!='.' && (data[y-1][x]=='.') && (data[y][x-1]=='.')
                                && (data[y+1][x]=='.') && (data[y][x+1]=='.')){
                if (data[y][x]=='w')
                    count_w++;
                else
                    count_b++;
                data[y][x]='.';
            }
        }
    }
    
    score += abs(count_w - count_b) + min(count_w,count_b)*10;
    
    cout << score << endl;

    return 0;
}
0