結果
| 問題 |
No.421 しろくろチョコレート
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2024-12-20 23:14:55 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 2,000 ms |
| コード長 | 1,584 bytes |
| コンパイル時間 | 1,373 ms |
| コンパイル使用メモリ | 122,112 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-20 23:15:03 |
| 合計ジャッジ時間 | 3,288 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 65 |
ソースコード
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cassert>
#include<utility>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define all(vc) vc.begin(),vc.end()
#define sz(vc) ((int)vc.size())
#define pb push_back
#define fi first
#define se second
#define x0 __x00
#define y0 __y00
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N=55,M=2505;
int n,m,mt[M];
char ch[N][N];
bool st[M];
vector<int>G[M];
int get(int x,int y){
return (x-1)*m+y;
}
void add(int a,int b,int c,int d){
G[get(a,b)].pb(get(c,d));
G[get(c,d)].pb(get(a,b));
}
bool dfs(int x){
st[x]=1;
for(auto to:G[x]){
int _=mt[to];
if(_<0||(!st[_]&&dfs(_))){
mt[x]=to,mt[to]=x;
return 1;
}
}return 0;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin>>n>>m;
rep(i,1,n)rep(j,1,m)cin>>ch[i][j];
int b,w;b=w=0;
rep(i,1,n)rep(j,1,m){
if(ch[i][j]=='.')continue;
b+=ch[i][j]=='b';
w+=ch[i][j]=='w';
if(i<n&&ch[i+1][j]!='.')add(i,j,i+1,j);
if(j<m&&ch[i][j+1]!='.')add(i,j,i,j+1);
}
memset(mt,-1,sizeof(mt));
int res=0;
rep(i,1,n*m)
if(mt[i]<0)memset(st,0,sizeof(st)),res+=dfs(i);
b-=res,w-=res;
cout<<res*100ll+min(b,w)*10+abs(b-w)<<'\n';
return 0;
}
vjudge1