結果
問題 | No.1479 Matrix Eraser |
ユーザー | tokusakurai |
提出日時 | 2021-04-16 20:34:52 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,680 bytes |
コンパイル時間 | 2,133 ms |
コンパイル使用メモリ | 207,888 KB |
実行使用メモリ | 23,452 KB |
最終ジャッジ日時 | 2023-09-15 21:29:58 |
合計ジャッジ時間 | 6,335 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 8 ms
14,652 KB |
testcase_01 | AC | 7 ms
14,744 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 15 ms
15,872 KB |
testcase_08 | AC | 23 ms
16,460 KB |
testcase_09 | AC | 45 ms
18,296 KB |
testcase_10 | AC | 78 ms
20,856 KB |
testcase_11 | AC | 47 ms
18,796 KB |
testcase_12 | AC | 19 ms
16,052 KB |
testcase_13 | AC | 22 ms
16,316 KB |
testcase_14 | AC | 18 ms
16,164 KB |
testcase_15 | AC | 10 ms
15,120 KB |
testcase_16 | AC | 20 ms
16,064 KB |
testcase_17 | AC | 97 ms
22,204 KB |
testcase_18 | AC | 94 ms
21,972 KB |
testcase_19 | AC | 94 ms
21,988 KB |
testcase_20 | AC | 95 ms
21,912 KB |
testcase_21 | AC | 94 ms
22,076 KB |
testcase_22 | AC | 96 ms
21,908 KB |
testcase_23 | AC | 95 ms
21,896 KB |
testcase_24 | AC | 93 ms
21,864 KB |
testcase_25 | AC | 95 ms
21,932 KB |
testcase_26 | AC | 95 ms
21,932 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | AC | 27 ms
17,808 KB |
testcase_33 | AC | 26 ms
17,920 KB |
testcase_34 | AC | 26 ms
17,840 KB |
testcase_35 | AC | 25 ms
17,788 KB |
testcase_36 | AC | 27 ms
17,956 KB |
testcase_37 | AC | 24 ms
17,776 KB |
testcase_38 | AC | 29 ms
17,904 KB |
testcase_39 | AC | 74 ms
23,452 KB |
testcase_40 | AC | 7 ms
14,872 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define rep2(i, x, n) for(int i = x; i <= n; i++) #define rep3(i, x, n) for(int i = x; i >= n; i--) #define each(e, v) for(auto &e: v) #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) (int)x.size() using ll = long long; using pii = pair<int, int>; using pil = pair<int, ll>; using pli = pair<ll, int>; using pll = pair<ll, ll>; const int MOD = 1000000007; //const int MOD = 998244353; const int inf = (1<<30)-1; const ll INF = (1LL<<60)-1; template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;}; template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;}; struct io_setup{ io_setup(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout << fixed << setprecision(15); } } io_setup; int main(){ int H, W; cin >> H >> W; vector<vector<int>> A(H, vector<int>(W)); rep(i, H){ rep(j, W){ cin >> A[i][j]; } } int MAX = 500000; vector<vector<pii>> ps(MAX+1); rep(i, H){ rep(j, W){ ps[A[i][j]].eb(i, j); } } vector<int> cx(H, 0), cy(W, 0); int sx = 0, sy = 0; ll ans = 0; rep3(i, MAX, 1){ each(e, ps[i]){ auto [x, y] = e; if(cx[x]++ == 0) sx++; if(cy[y]++ == 0) sy++; } ans += min(sx, sy); sx = 0, sy = 0; each(e, ps[i]){ auto [x, y] = e; cx[x]--, cy[y]--; } } cout << ans << '\n'; }