結果
問題 | No.1479 Matrix Eraser |
ユーザー |
![]() |
提出日時 | 2021-04-16 20:38:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 852 bytes |
コンパイル時間 | 1,964 ms |
コンパイル使用メモリ | 183,632 KB |
実行使用メモリ | 63,744 KB |
最終ジャッジ日時 | 2024-07-02 23:03:10 |
合計ジャッジ時間 | 11,943 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 WA * 10 |
ソースコード
#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; }