結果

問題 No.2958 Placing Many L-s
ユーザー 👑 binapbinap
提出日時 2024-05-12 12:04:20
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 999 bytes
コンパイル時間 4,301 ms
コンパイル使用メモリ 262,884 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-08 20:50:11
合計ジャッジ時間 10,558 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 5 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using namespace atcoder;

int main(){
	int n, m;
	cin >> n >> m;
	bool FLIP = false;
	if(n % 4 == 0 && m % 2 == 0){
		swap(n, m);
		FLIP = true;
	}
	if(n % 2 == 0 && m % 4 == 0){
		int k = n * m / 4;
		int n2 = n / 2;
		int m2 = m / 4;
		vector<vector<int>> a(n, vector<int>(m));
		int cnt = 0;
		rep(i, n2) rep(j, m2){
			a[2 * i][4 * j] = cnt + 1;
			a[2 * i][4 * j + 1] = cnt + 1;
			a[2 * i][4 * j + 2] = cnt + 1;
			a[2 * i][4 * j + 3] = cnt + 2;
			a[2 * i + 1][4 * j] = cnt + 1;
			a[2 * i + 1][4 * j + 1] = cnt + 2;
			a[2 * i + 1][4 * j + 2] = cnt + 2;
			a[2 * i + 1][4 * j + 3] = cnt + 2;
			cnt += 2;
		}
		cout << k << "\n";
		if(FLIP){
			vector<vector<int>> a_old(m, vector<int>(n));
			swap(a, a_old);
			rep(i, n) rep(j, m) a[j][i] = a_old[i][j];
			swap(n, m);
		}
		rep(i, n){
			rep(j, m) cout << a[i][j] << (j == m - 1 ? "\n" : " ");
		}
	}else cout << "-1\n";
	return 0;
}
0