結果

問題 No.2112 All 2x2 are Equal
コンテスト
ユーザー C
提出日時 2026-11-04 21:18:47
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc16.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 20 ms / 2,000 ms
+ 31µs
コード長 1,600 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,078 ms
コンパイル使用メモリ 390,808 KB
実行使用メモリ 9,868 KB
最終ジャッジ日時 2026-11-04 21:19:16
合計ジャッジ時間 17,450 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/polygon/point_data.hpp>
#include <boost/polygon/voronoi.hpp>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(x) begin(x),end(x)
#define sz(x) (int)(x).size()
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pll=pair<ll,ll>;
using pi=pair<int,int>;

// using mint=modint998244353;
using mint=modint1000000007;
// using mint2=static_modint<2>;

// using BoostPoint=boost::polygon::point_data<int>;
// using Voronoi=boost::polygon::voronoi_diagram<double>;

// using mint=LazyMontgomeryModInt<998244353>;
using vm=vector<mint>;
// using vvm=vector<vm>;

int main()
{
  	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	/**
	 * 天才構築、苦手すぎる(確かに面白いですが)
	 * 
	 * A_{ij} = W*r_{ij} + c_{ij} として考えます
	 * 
	 * もし全ての(i,j)について
	 * 
	 * r_{ij} + r_{i(j+1)} = H - 1 
	 * 
	 * c_{ij} + c_{(i+1)j} = W + 1
	 * 
	 * であれば、問題の条件が満たされます(S = 2(HW+1))
	 * 
	 * そのため、以下のように定義します
	 * 
	 * r_{ij} = (j が奇数?) H - 1 - i : i
	 * 
	 * c_{ij} = (r_{ij} が奇数?) W - j : j + 1
	 */
	int H,W;
	cin>>H>>W;
	cout<<"Yes\n";
	string row;
	row.reserve(8*W);
	rep(i,0,H){
		row.clear();
		rep(j,0,W){
			int r=(j&1)?H-1-i:i;
			int c=(r&1)?W-j:j+1;
			row+=to_string(W*r+c);
			row+=(j+1==W?'\n':' ');
		}
		cout<<row;
	}
}
0