結果

問題 No.421 しろくろチョコレート
ユーザー firiexp
提出日時 2019-11-26 15:15:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,273 bytes
コンパイル時間 923 ms
コンパイル使用メモリ 90,416 KB
最終ジャッジ日時 2024-11-15 04:49:21
合計ジャッジ時間 1,398 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:71:19: error: variable 'std::array<int, 4> dx' has initializer but incomplete type
   71 |     array<int, 4> dx{-1, 1, 0, 0}, dy{0, 0, -1, 1};
      |                   ^~
main.cpp:71:36: error: variable 'std::array<int, 4> dy' has initializer but incomplete type
   71 |     array<int, 4> dx{-1, 1, 0, 0}, dy{0, 0, -1, 1};
      |                                    ^~

ソースコード

diff #
プレゼンテーションモードにする

#include <limits>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;
template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;
class Bipartite_Matching {
vector<vector<int>> G;
vector<int> used, alive;
int t;
public:
vector<int> match;
explicit Bipartite_Matching(int n): t(0), G(n), used(n, 0), alive(n, -1), match(n, -1) {};
void add_edge(int a, int b){
G[a].emplace_back(b);
G[b].emplace_back(a);
}
bool dfs(int x){
used[x] = t;
for (auto &&i : G[x]) {
int w = match[i];
if(alive[i] == 0) continue;
if(w == -1 || (used[w] != t && dfs(w))){
match[x] = i;
match[i] = x;
return true;
}
}
return false;
}
int matching() {
int ans = 0;
for (int i = 0; i < G.size(); ++i) {
if(alive[i] == 0) continue;
if(match[i] == -1) {
++t;
ans += dfs(i);
}
}
return ans;
}
};
int main() {
int h, w;
cin >> h >> w;
vector<vector<int>> v(h+2, vector<int> (w+2, 0));
for (int i = 0; i < h; ++i) {
string s;
cin >> s;
for (int j = 0; j < w; ++j) {
v[i+1][j+1] = s[j] != '.';
}
}
Bipartite_Matching G(h*w);
array<int, 4> dx{-1, 1, 0, 0}, dy{0, 0, -1, 1};
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if(!v[i+1][j+1]) continue;
for (int k = 0; k < 4; ++k) {
if(v[i+1+dy[k]][j+1+dx[k]]){
G.add_edge(i*w+j, (i+dy[k])*w+j+dx[k]);
}
}
}
}
ll ans = G.matching()*100, a = 0, b = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if(!v[i+1][j+1]) continue;
if(!(~G.match[i*w+j])){
((i+j)%2 ? a : b)++;
}
}
}
cout << ans + min(a, b)*9 + max(a, b);
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0