結果

問題 No.1479 Matrix Eraser
ユーザー HaaHaa
提出日時 2021-04-16 20:38:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 852 bytes
コンパイル時間 1,701 ms
コンパイル使用メモリ 182,376 KB
実行使用メモリ 63,608 KB
最終ジャッジ日時 2023-09-15 21:36:12
合計ジャッジ時間 10,858 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 37 ms
9,856 KB
testcase_08 AC 66 ms
14,872 KB
testcase_09 AC 158 ms
27,656 KB
testcase_10 AC 356 ms
47,724 KB
testcase_11 AC 198 ms
31,832 KB
testcase_12 AC 47 ms
12,020 KB
testcase_13 AC 65 ms
14,820 KB
testcase_14 AC 49 ms
12,288 KB
testcase_15 AC 10 ms
5,100 KB
testcase_16 AC 57 ms
13,240 KB
testcase_17 AC 459 ms
56,396 KB
testcase_18 AC 457 ms
56,116 KB
testcase_19 AC 455 ms
56,124 KB
testcase_20 AC 448 ms
56,120 KB
testcase_21 AC 443 ms
56,168 KB
testcase_22 AC 434 ms
56,176 KB
testcase_23 AC 453 ms
56,184 KB
testcase_24 AC 463 ms
56,212 KB
testcase_25 AC 454 ms
56,184 KB
testcase_26 AC 459 ms
56,148 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 60 ms
5,380 KB
testcase_33 AC 60 ms
5,376 KB
testcase_34 AC 61 ms
5,388 KB
testcase_35 AC 61 ms
5,444 KB
testcase_36 AC 61 ms
5,376 KB
testcase_37 AC 37 ms
5,416 KB
testcase_38 AC 268 ms
29,120 KB
testcase_39 AC 241 ms
63,608 KB
testcase_40 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=998244353;
constexpr ll INF=2e18;

int main(){
    int h, w; cin >> h >> w;
    VVI a(h,VI(w));
    REP(i,h)REP(j,w) cin >> a[i][j];
    map<int,int> mp; int k=1;
    REP(i,h)REP(j,w){
        if(a[i][j]==0)
            continue;
        if(mp[a[i][j]]==0){
            mp[a[i][j]]=k;
            k++;
        }
    }
    vector<set<int>> x(k), y(k);
    REP(i,h)REP(j,w){
        if(a[i][j]==0)
            continue;
        int p=mp[a[i][j]]-1;
        x[p].insert(i);
        y[p].insert(j);
    }
    int ans=0;
    REP(i,k-1){
        ans+=min(x[i].size(),y[i].size());
    }
    cout << ans << endl;
    return 0;
}
0