結果

問題 No.1479 Matrix Eraser
ユーザー ayoiyouyoeyoayoiyouyoeyo
提出日時 2021-04-16 20:24:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,979 bytes
コンパイル時間 3,773 ms
コンパイル使用メモリ 182,136 KB
実行使用メモリ 75,720 KB
最終ジャッジ日時 2023-09-15 21:07:17
合計ジャッジ時間 19,261 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 78 ms
11,860 KB
testcase_08 AC 154 ms
17,548 KB
testcase_09 AC 347 ms
32,660 KB
testcase_10 AC 743 ms
55,892 KB
testcase_11 AC 445 ms
37,580 KB
testcase_12 AC 101 ms
14,004 KB
testcase_13 AC 148 ms
17,688 KB
testcase_14 AC 110 ms
14,552 KB
testcase_15 AC 16 ms
5,864 KB
testcase_16 AC 121 ms
15,868 KB
testcase_17 AC 939 ms
65,728 KB
testcase_18 AC 930 ms
65,764 KB
testcase_19 AC 937 ms
65,716 KB
testcase_20 AC 947 ms
65,700 KB
testcase_21 AC 914 ms
65,848 KB
testcase_22 AC 908 ms
65,676 KB
testcase_23 AC 945 ms
65,736 KB
testcase_24 AC 929 ms
65,860 KB
testcase_25 AC 903 ms
65,772 KB
testcase_26 AC 930 ms
65,920 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 59 ms
5,600 KB
testcase_33 AC 59 ms
5,456 KB
testcase_34 AC 59 ms
5,452 KB
testcase_35 AC 59 ms
5,456 KB
testcase_36 AC 58 ms
5,596 KB
testcase_37 AC 50 ms
5,600 KB
testcase_38 AC 309 ms
28,988 KB
testcase_39 AC 561 ms
75,720 KB
testcase_40 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<bitset>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include<cassert>
#include<random>
using namespace std;
#include<atcoder/all>
using namespace atcoder;


#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e17;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll id;
	ll fr;
	ll to;
	ll d;
};

using mint = modint;

typedef vector<ll> vll;
typedef vector <vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

vmint f, finv, inv;

void cominit(ll N) {
	ll MOD = modint::mod();//デフォルトが998244353に注意

	f.assign(N + 1, 1);
	finv.assign(N + 1, 1);
	inv.assign(N + 1, 1);
	inv[1] = 1;

	repn(i, N) {
		f[i] = f[i - 1] * i;
		if (i > 1)inv[i] = -inv[MOD % i] * (MOD / i);
		finv[i] = finv[i - 1] * inv[i];
	}
}

mint com(ll a, ll b) {
	if (a < 0 || b < 0 || a < b) { return 0; }
	return f[a] * finv[b] * finv[a - b];
}


/////////////////////////////////////


int main() {
	ll H, W;
	cin >> H >> W;

	vvll A(H, vll(W, 0));
	rep(i, H)rep(j, W)cin >> A[i][j];

	map<ll, set<ll>> tate;
	map<ll, set<ll>> yoko;

	rep(i, H)rep(j, W) {
		tate[A[i][j]].insert(i);
		yoko[A[i][j]].insert(j);
	}

	ll ans = 0;
	for (auto p : tate) {
		ll x = p.first;
		if (x == 0) { continue; }
		ans += min(tate[x].size(), yoko[x].size());
		
	}
	cout << ans << endl;


	
	

}
0