結果
問題 |
No.1479 Matrix Eraser
|
ユーザー |
|
提出日時 | 2021-04-16 22:20:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,860 bytes |
コンパイル時間 | 3,640 ms |
コンパイル使用メモリ | 184,352 KB |
実行使用メモリ | 22,912 KB |
最終ジャッジ日時 | 2024-07-03 02:16:59 |
合計ジャッジ時間 | 12,192 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 TLE * 1 -- * 31 |
コンパイルメッセージ
main.cpp: In function 'void solve()': main.cpp:42:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 42 | for(auto [a, as] : A) { | ^
ソースコード
#include <atcoder/all> #include <bitset> #include <fstream> #include <functional> #include <iostream> #include <iomanip> #include <limits> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; using namespace atcoder; //* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *// void input() { } void solve() { int H, W; cin >> H >> W; map<int, set<int>> A; for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { int a; cin >> a; A[a].insert(i * W + j); } } int ans = 0; for(auto [a, as] : A) { if(a == 0) continue; atcoder::mf_graph<int> G(H + W + 2); for(int i = 0; i < H; i++) { G.add_edge(H + W, i, 1); } for(int j = 0; j < W; j++) { G.add_edge(H + j, H + W + 1, 1); } for(auto b : as) { G.add_edge(b / W, H + b % W, 1); } ans += G.flow(H+W, H+W+1); } cout << ans << endl; // set<int> As; // map<int, bitset<500>> Ac, Ar; // for(int i = 0; i < H; i++) { // for(int j = 0; j < W; j++) { // int A; cin >> A; // As.insert(A); // Ac[A].set(i); // Ar[A].set(j); // } // } // // int ans = 0; // for(auto a : As) { // if(a == 0) continue; // ans += min(Ac[a].count(), Ar[a].count()); // } // cout << ans << endl; } //* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *// int main() { std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf()); std::cin.tie(0); ios::sync_with_stdio(false); input(); solve(); return 0; }