結果
問題 | No.1479 Matrix Eraser |
ユーザー | 👑 PCTprobability |
提出日時 | 2021-03-05 20:55:56 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 408 ms / 3,000 ms |
コード長 | 2,005 bytes |
コンパイル時間 | 5,117 ms |
コンパイル使用メモリ | 272,576 KB |
実行使用メモリ | 25,696 KB |
最終ジャッジ日時 | 2024-04-16 16:54:54 |
合計ジャッジ時間 | 12,992 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 43 ms
5,924 KB |
testcase_08 | AC | 75 ms
7,660 KB |
testcase_09 | AC | 167 ms
12,592 KB |
testcase_10 | AC | 312 ms
18,480 KB |
testcase_11 | AC | 193 ms
13,616 KB |
testcase_12 | AC | 54 ms
6,400 KB |
testcase_13 | AC | 76 ms
7,924 KB |
testcase_14 | AC | 57 ms
6,660 KB |
testcase_15 | AC | 13 ms
5,376 KB |
testcase_16 | AC | 66 ms
7,552 KB |
testcase_17 | AC | 395 ms
22,276 KB |
testcase_18 | AC | 399 ms
22,280 KB |
testcase_19 | AC | 394 ms
22,408 KB |
testcase_20 | AC | 389 ms
22,400 KB |
testcase_21 | AC | 407 ms
22,404 KB |
testcase_22 | AC | 408 ms
22,284 KB |
testcase_23 | AC | 400 ms
22,540 KB |
testcase_24 | AC | 392 ms
22,416 KB |
testcase_25 | AC | 402 ms
22,404 KB |
testcase_26 | AC | 394 ms
22,272 KB |
testcase_27 | AC | 114 ms
9,344 KB |
testcase_28 | AC | 113 ms
9,344 KB |
testcase_29 | AC | 114 ms
9,216 KB |
testcase_30 | AC | 114 ms
9,216 KB |
testcase_31 | AC | 115 ms
9,344 KB |
testcase_32 | AC | 55 ms
14,176 KB |
testcase_33 | AC | 54 ms
14,248 KB |
testcase_34 | AC | 54 ms
14,276 KB |
testcase_35 | AC | 55 ms
14,192 KB |
testcase_36 | AC | 54 ms
14,248 KB |
testcase_37 | AC | 15 ms
5,376 KB |
testcase_38 | AC | 161 ms
7,680 KB |
testcase_39 | AC | 324 ms
25,696 KB |
testcase_40 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif using ll = long long; using ld = long double; #define all(s) (s).begin(),(s).end() #define vcin(n) for(ll i=0;i<ll(n.size());i++) cin>>n[i] #define rep2(i, m, n) for (int i = (m); i < (n); ++i) #define rep(i, n) rep2(i, 0, n) #define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i) #define drep(i, n) drep2(i, n, 0) #define rever(vec) reverse(vec.begin(), vec.end()) #define sor(vec) sort(vec.begin(), vec.end()) #define fi first #define se second #define P pair<ll,ll> const ll mod = 998244353; //const ll mod = 1000000007; const ll inf = 2000000000000000000ll; static const long double pi = 3.141592653589793; void YesNo(bool a){if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}} void YESNO(bool a){if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}} template<class T,class U> void chmax(T& t,const U& u){if(t<u) t=u;} template<class T,class U> void chmin(T& t,const U& u){if(t>u) t=u;} ll modPow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; } int main() { /* mod は 1e9+7 */ ios::sync_with_stdio(false); std::cin.tie(nullptr); cout<< fixed << setprecision(10); ll a,b; cin>>a>>b; unordered_map<ll,vector<pair<ll,ll>>> m; for(int i=0;i<a;i++){ for(int j=0;j<b;j++){ ll t; cin>>t; if(t){ m[t].emplace_back(i,j); } } } ll ans=0; for(auto &x:m){ unordered_map<ll,ll> p,q; ll u=1,v=1; for(auto &y:x.se){ if(p[y.fi]==0){ p[y.fi]=u; u++; } if(q[y.se]==0){ q[y.se]=v; v++; } } mf_graph<ll> g(u+v+2); for(int j=0;j<u;j++){ g.add_edge(u+v,j,1); } for(int j=0;j<v;j++){ g.add_edge(u+j,u+v+1,1); } for(auto &h:x.se){ g.add_edge(p[h.fi]-1,u+q[h.se]-1,1); } ans+=g.flow(u+v,u+v+1); } cout<<ans<<endl; }