結果

問題 No.1479 Matrix Eraser
ユーザー jutamajutama
提出日時 2021-04-16 22:20:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,860 bytes
コンパイル時間 3,329 ms
コンパイル使用メモリ 183,364 KB
実行使用メモリ 21,880 KB
最終ジャッジ日時 2023-09-16 01:09:51
合計ジャッジ時間 11,998 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
21,880 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1,266 ms
7,524 KB
testcase_08 AC 2,359 ms
10,376 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘void solve()’ 内:
main.cpp:42:14: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   42 |     for(auto [a, as] : A) {
      |              ^

ソースコード

diff #

#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;
}
0