結果
| 問題 |
No.2958 Placing Many L-s
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2024-11-08 22:08:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,162 bytes |
| コンパイル時間 | 4,107 ms |
| コンパイル使用メモリ | 251,936 KB |
| 最終ジャッジ日時 | 2025-02-25 02:49:26 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 WA * 14 |
ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000000LL
int main(){
int _t;
cin>>_t;
rep(_,_t){
int n,m;
cin>>n>>m;
if(n%2||m%2||(n%4&&m%4)){
cout<<-1<<endl;
continue;
}
cout<<(n*m)/4<<endl;
vector<vector<int>> a(n,vector<int>(m));
if(m%4==0){
int cur = 1;
for(int i=0;i<n;i+=2){
for(int j=0;j<m;j+=4){
a[i][j] = cur;
a[i+1][j] = cur;
a[i][j+1] = cur;
a[i][j+2] = cur;
cur++;
a[i][j+3] = cur;
a[i+1][j+1] = cur;
a[i+1][j+2] = cur;
a[i+1][j+3] = cur;
cur++;
}
}
}
else{
int cur = 1;
for(int i=0;i<n;i+=4){
for(int j=0;j<m;j+=2){
a[i+1][j] = cur;
a[i+2][j] = cur;
a[i+3][j] = cur;
a[i+3][j+1] = cur;
cur++;
a[i][j] = cur;
a[i][j+1] = cur;
a[i+1][j+1] = cur;
a[i+2][j+1] = cur;
cur++;
}
}
}
rep(i,n){
rep(j,m){
if(j!=0)cout<<' ';
cout<<a[i][j];
}
cout<<endl;
}
}
return 0;
}
沙耶花