結果
問題 | No.1479 Matrix Eraser |
ユーザー | kotatsugame |
提出日時 | 2021-04-24 05:31:07 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,294 bytes |
コンパイル時間 | 896 ms |
コンパイル使用メモリ | 84,696 KB |
実行使用メモリ | 7,904 KB |
最終ジャッジ日時 | 2023-09-17 13:28:05 |
合計ジャッジ時間 | 40,189 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 188 ms
4,380 KB |
testcase_08 | AC | 351 ms
4,376 KB |
testcase_09 | AC | 896 ms
4,484 KB |
testcase_10 | AC | 2,104 ms
5,416 KB |
testcase_11 | AC | 1,128 ms
4,684 KB |
testcase_12 | AC | 271 ms
4,376 KB |
testcase_13 | AC | 316 ms
4,380 KB |
testcase_14 | AC | 271 ms
4,376 KB |
testcase_15 | AC | 34 ms
4,376 KB |
testcase_16 | AC | 260 ms
4,376 KB |
testcase_17 | AC | 2,692 ms
5,948 KB |
testcase_18 | AC | 2,699 ms
5,952 KB |
testcase_19 | AC | 2,686 ms
5,980 KB |
testcase_20 | AC | 2,696 ms
5,876 KB |
testcase_21 | AC | 2,691 ms
6,004 KB |
testcase_22 | AC | 2,691 ms
5,896 KB |
testcase_23 | AC | 2,689 ms
6,008 KB |
testcase_24 | AC | 2,686 ms
6,076 KB |
testcase_25 | AC | 2,701 ms
5,952 KB |
testcase_26 | AC | 2,698 ms
5,840 KB |
testcase_27 | AC | 115 ms
6,248 KB |
testcase_28 | AC | 115 ms
6,140 KB |
testcase_29 | AC | 115 ms
5,948 KB |
testcase_30 | AC | 114 ms
6,012 KB |
testcase_31 | AC | 115 ms
6,064 KB |
testcase_32 | AC | 67 ms
7,696 KB |
testcase_33 | AC | 66 ms
7,904 KB |
testcase_34 | AC | 67 ms
7,532 KB |
testcase_35 | AC | 71 ms
7,816 KB |
testcase_36 | AC | 67 ms
7,652 KB |
testcase_37 | AC | 47 ms
6,152 KB |
testcase_38 | AC | 103 ms
5,940 KB |
testcase_39 | TLE | - |
testcase_40 | AC | 1 ms
4,376 KB |
コンパイルメッセージ
a.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
ソースコード
#line 1 "a.cpp" #include<iostream> #include<vector> #include<algorithm> using namespace std; #line 3 "/home/kotatsugame/library/graph/bimatch.cpp" struct bimatch{ int n; vector<vector<int> >G; vector<int>match; vector<bool>used; bimatch(int _n=0):n(_n),G(n),match(n),used(n){} void add_edge(int u,int v) { G[u].push_back(v); G[v].push_back(u); } bool dfs(int v) { used[v]=true; for(int u:G[v]) { int w=match[u]; if(w<0||!used[w]&&dfs(w)) { match[v]=u; match[u]=v; return true; } } return false; } int count() { int ans=0; bool flag=true; fill(match.begin(),match.end(),-1); while(flag) { flag=false; fill(used.begin(),used.end(),false); for(int v=0;v<n;v++)if(match[v]<0&&dfs(v))ans++,flag=true; } return ans; } }; #line 6 "a.cpp" int N,M; main() { cin>>N>>M; vector<pair<int,pair<int,int> > >A(N*M); for(int i=0;i<N;i++)for(int j=0;j<M;j++) { cin>>A[i*M+j].first; A[i*M+j].second=make_pair(i,j); } sort(A.begin(),A.end()); int ans=0; for(int i=0;i<A.size();) { if(A[i].first==0) { i++; continue; } int j=i; bimatch P(N+M); while(j<A.size()&&A[i].first==A[j].first) { P.add_edge(A[j].second.first,A[j].second.second+N); j++; } i=j; ans+=P.count(); } cout<<ans<<endl; }