結果
| 問題 |
No.2958 Placing Many L-s
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2024-11-08 22:01:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,615 bytes |
| コンパイル時間 | 849 ms |
| コンパイル使用メモリ | 80,900 KB |
| 最終ジャッジ日時 | 2025-02-25 02:47:32 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 WA * 14 |
ソースコード
#ifdef NACHIA
#define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<int(n); i++)
const i64 INF = 1001001001001001001;
template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; }
template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; }
#include <atcoder/modint>
using Modint = atcoder::static_modint<998244353>;
using namespace std;
void testcase(){
int N, M; cin >> N >> M;
if(N % 2 == 1 || M % 2 == 1){ cout << "-1\n"; return; }
if(N % 4 == 2 && M % 4 == 2){ cout << "-1\n"; return; }
bool f = M % 4 == 2;
if(f) swap(N, M);
vector<vector<int>> ans(N, vector<int>(M));
rep(i,N/2) rep(j,M/4){
int x = j * N + i * 2 + 1;
ans[i*2+0][j*4+0] = x+0;
ans[i*2+0][j*4+1] = x+0;
ans[i*2+0][j*4+2] = x+0;
ans[i*2+0][j*4+3] = x+1;
ans[i*2+1][j*4+0] = x+0;
ans[i*2+1][j*4+1] = x+1;
ans[i*2+1][j*4+2] = x+1;
ans[i*2+1][j*4+3] = x+1;
}
if(f) swap(N, M);
cout << (N*M/4) << "\n";
if(f){
rep(i,N){
rep(j,M){
if(j) cout << " ";
cout << ans[j][i];
} cout << "\n";
}
} else {
rep(i,N){
rep(j,M){
if(j) cout << " ";
cout << ans[i][j];
} cout << "\n";
}
}
}
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
int T; cin >> T;
rep(t,T) testcase();
return 0;
}
Nachia