結果
問題 |
No.1479 Matrix Eraser
|
ユーザー |
|
提出日時 | 2021-04-16 22:25:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,543 bytes |
コンパイル時間 | 3,844 ms |
コンパイル使用メモリ | 189,748 KB |
実行使用メモリ | 70,912 KB |
最終ジャッジ日時 | 2024-07-03 02:25:38 |
合計ジャッジ時間 | 12,015 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 TLE * 1 -- * 30 |
コンパイルメッセージ
main.cpp: In function 'void solve()': main.cpp:45:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 45 | 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, bitset<500>> Ac, Ar; 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); Ac[a].set(i); Ar[a].set(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++) { if(Ac[a].test(i)) G.add_edge(H + W, i, 1); } for(int j = 0; j < W; j++) { if(Ar[a].test(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; } //* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *// 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; }