結果
| 問題 |
No.421 しろくろチョコレート
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-09 23:54:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,663 bytes |
| コンパイル時間 | 1,548 ms |
| コンパイル使用メモリ | 169,260 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-16 18:47:39 |
| 合計ジャッジ時間 | 3,026 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 47 WA * 18 |
ソースコード
//
// 気合で
//
#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=height;0<=y;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;
}