結果

問題 No.1479 Matrix Eraser
ユーザー norikamenorikame
提出日時 2021-04-16 22:52:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 838 bytes
コンパイル時間 2,409 ms
コンパイル使用メモリ 213,124 KB
実行使用メモリ 30,680 KB
最終ジャッジ日時 2023-09-16 02:01:39
合計ジャッジ時間 9,733 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 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 26 ms
6,440 KB
testcase_08 AC 50 ms
8,608 KB
testcase_09 AC 131 ms
13,976 KB
testcase_10 AC 285 ms
21,972 KB
testcase_11 AC 160 ms
15,660 KB
testcase_12 AC 35 ms
7,280 KB
testcase_13 AC 50 ms
8,744 KB
testcase_14 AC 36 ms
7,468 KB
testcase_15 AC 8 ms
4,376 KB
testcase_16 AC 41 ms
7,956 KB
testcase_17 AC 346 ms
24,952 KB
testcase_18 AC 348 ms
24,960 KB
testcase_19 AC 351 ms
25,064 KB
testcase_20 AC 346 ms
25,112 KB
testcase_21 AC 345 ms
24,964 KB
testcase_22 AC 339 ms
25,016 KB
testcase_23 AC 348 ms
24,968 KB
testcase_24 AC 349 ms
24,952 KB
testcase_25 AC 345 ms
25,040 KB
testcase_26 AC 348 ms
25,008 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 58 ms
5,120 KB
testcase_33 AC 58 ms
5,108 KB
testcase_34 AC 57 ms
5,116 KB
testcase_35 AC 58 ms
5,188 KB
testcase_36 AC 57 ms
5,216 KB
testcase_37 AC 37 ms
5,104 KB
testcase_38 AC 105 ms
5,452 KB
testcase_39 AC 236 ms
30,680 KB
testcase_40 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

int main() {
	int h, w;
	cin >> h >> w;
	map<int, vector<pair<int, int>>> aval;
	rep(i, h) rep(j, w) {
		int ai;
		cin >> ai;
		aval[ai].emplace_back(i, j);
	}
	int res = 0;
	for (auto itr=aval.rbegin(); itr!=aval.rend(); ++itr) {
		if (itr->first == 0) continue;
		map<int, int> hcnt, wcnt;
		rep(i, (int)(itr->second.size())) {
			hcnt[itr->second[i].first]++;
			wcnt[itr->second[i].second]++;
		}
		res += min((int)(hcnt.size()), (int)(wcnt.size()));
	}
	cout << res << endl;
	return 0;
}

0