結果

問題 No.1910 High Element on Grid
ユーザー kabipoyokabipoyo
提出日時 2022-04-22 22:22:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 1,640 bytes
コンパイル時間 2,840 ms
コンパイル使用メモリ 204,764 KB
実行使用メモリ 5,368 KB
最終ジャッジ日時 2023-09-06 08:55:56
合計ジャッジ時間 9,866 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,388 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 27 ms
4,768 KB
testcase_12 AC 27 ms
4,836 KB
testcase_13 AC 27 ms
4,852 KB
testcase_14 AC 32 ms
5,076 KB
testcase_15 AC 22 ms
4,520 KB
testcase_16 AC 18 ms
4,400 KB
testcase_17 AC 20 ms
4,552 KB
testcase_18 AC 27 ms
4,796 KB
testcase_19 AC 21 ms
4,492 KB
testcase_20 AC 21 ms
4,464 KB
testcase_21 AC 26 ms
4,708 KB
testcase_22 AC 17 ms
4,380 KB
testcase_23 AC 29 ms
5,012 KB
testcase_24 AC 19 ms
4,504 KB
testcase_25 AC 25 ms
4,672 KB
testcase_26 AC 23 ms
4,660 KB
testcase_27 AC 23 ms
4,692 KB
testcase_28 AC 16 ms
4,380 KB
testcase_29 AC 18 ms
4,448 KB
testcase_30 AC 21 ms
4,412 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 37 ms
5,336 KB
testcase_33 AC 37 ms
5,312 KB
testcase_34 AC 37 ms
5,368 KB
testcase_35 AC 37 ms
5,340 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 18 ms
4,396 KB
testcase_38 AC 8 ms
4,380 KB
testcase_39 AC 9 ms
4,376 KB
testcase_40 AC 3 ms
4,376 KB
testcase_41 AC 11 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<lint>;
using vvi = vector<vector<lint>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr lint LINF = LLONG_MAX/2;

int main() {
	lint H, W;
	cin >> H >> W;
	vi v(H), w(W);
	vin(v);
	vin(w);

	lint a=0, b=0, c=0, x, y, z;
	vvi m(H, vi(W, 1));
	m[0][0] = 100100100;
	repx(i, 1, H) {
		a = i;
		rep(j, W) {
			m[i][j] = ++a;
		}
	}
	repx(i, 1, H) {
		lint ng = 100100100, mid, ok = 1;
		while (abs(ok - ng) > 1) {
			mid = (ok + ng) / 2;
			a = mid, b = 1;
			repx(j, 1, W) {
				if (chmax(a, m[i][j])) b++;
			}
			if (b < v[i]) ng = mid;
			else ok = mid;
		}
		m[i][0] = ok;
	}
	repx(j, 1, W) {
		lint ng = 100100100, mid, ok = 1;
		while (abs(ok - ng) > 1) {
			mid = (ok + ng) / 2;
			a = mid, b = 1;
			repx(i, 1, H) {
				if (chmax(a, m[i][j])) b++;
			}
			if (b < w[j]) ng = mid;
			else ok = mid;
		}
		m[0][j] = ok;
	}
	rep(i, H) vout(m[i]);
}
0