結果
問題 | No.1479 Matrix Eraser |
ユーザー | jutama |
提出日時 | 2021-04-16 23:20:04 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,829 bytes |
コンパイル時間 | 4,088 ms |
コンパイル使用メモリ | 205,908 KB |
実行使用メモリ | 117,232 KB |
最終ジャッジ日時 | 2023-09-16 02:50:56 |
合計ジャッジ時間 | 60,433 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 294 ms
15,620 KB |
testcase_08 | AC | 574 ms
24,736 KB |
testcase_09 | AC | 1,423 ms
46,868 KB |
testcase_10 | TLE | - |
testcase_11 | AC | 1,750 ms
53,444 KB |
testcase_12 | AC | 449 ms
18,760 KB |
testcase_13 | AC | 508 ms
24,692 KB |
testcase_14 | AC | 446 ms
19,480 KB |
testcase_15 | AC | 61 ms
7,156 KB |
testcase_16 | AC | 415 ms
22,540 KB |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
testcase_27 | AC | 243 ms
15,460 KB |
testcase_28 | AC | 246 ms
15,492 KB |
testcase_29 | AC | 252 ms
15,392 KB |
testcase_30 | AC | 252 ms
15,460 KB |
testcase_31 | AC | 252 ms
15,632 KB |
testcase_32 | AC | 122 ms
24,492 KB |
testcase_33 | AC | 120 ms
24,524 KB |
testcase_34 | AC | 122 ms
24,484 KB |
testcase_35 | AC | 124 ms
24,420 KB |
testcase_36 | AC | 128 ms
24,480 KB |
testcase_37 | AC | 73 ms
24,276 KB |
testcase_38 | AC | 186 ms
13,648 KB |
testcase_39 | TLE | - |
testcase_40 | AC | 2 ms
4,380 KB |
ソースコード
#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; unordered_map<int, bitset<500>> Ac, Ar; unordered_map<int, unordered_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; int acc = 0, arc = 0; vector<int> ac(H, -1), ar(W, -1); for(int i = 0; i < H; i++) { if(Ac[a].test(i)) ac[i] = acc++; } for(int j = 0; j < W; j++) { if(Ar[a].test(j)) ar[j] = arc++; } int Gs = acc + arc; atcoder::mf_graph<int> G(Gs + 2); for(int i = 0; i < acc; i++) { G.add_edge(Gs, i, 1); } for(int j = 0; j < arc; j++) { G.add_edge(acc + j, Gs+1, 1); } for(auto b : as) { G.add_edge(ac[b/W], acc + ar[b%W], 1); } ans += G.flow(Gs, Gs+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; }