結果

問題 No.2663 Zero-Sum Submatrices
ユーザー shobonvipshobonvip
提出日時 2024-03-08 21:11:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,933 bytes
コンパイル時間 4,406 ms
コンパイル使用メモリ 266,112 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-08 21:11:43
合計ジャッジ時間 5,886 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 3 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 3 ms
6,676 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
testcase_30 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

vector<vector<int>> solve(vector<vector<int>> now, int r){
	if (r == 0) return now;
	
	int n = now.size();
	int m = now[0].size();
	vector<vector<int>> ret(n * 2, vector<int>(m * 2));
	rep(i,0,n){
		rep(j,0,m){
			int b = now[i][j] * 4;
			ret[i*2][j*2] = b;
			ret[i*2][j*2+1] = b + 1;
			ret[i*2+1][j*2+1] = b + 2;
			ret[i*2+1][j*2] = b + 3;
		}
	}

	return solve(ret, r - 1);
}

int main(){
	int n, m; cin >> n >> m;
	
	vector<vector<int>> tar(1, vector<int>(1));
	if (n > m){
		tar.resize(1 << (n - m));
		rep(i,0,1<<(n-m)){
			tar[i].resize(1);
		}
		rep(i,0,1<<(n-m)){
			tar[i][0] = i;
		}
	}else if(n < m){
		tar[0].resize(1 << (m - n));
		rep(i,0,1<<(m-n)){
			tar[0][i] = i;
		}
	}

	vector<vector<int>> g = solve(tar, min(n, m));

	assert(g.size() == (1 << n));
	assert(g[0].size() == (1 << m));

	rep(i,0,1<<n){
		rep(j,0,1<<m){
			cout << g[i][j] << ' ';
		}
		cout << '\n';
	}
}

0