結果
| 問題 |
No.1851 Regular Tiling
|
| コンテスト | |
| ユーザー |
蜜蜂
|
| 提出日時 | 2021-03-23 14:42:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 75 ms / 2,000 ms |
| コード長 | 1,139 bytes |
| コンパイル時間 | 2,761 ms |
| コンパイル使用メモリ | 172,448 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-03 15:24:43 |
| 合計ジャッジ時間 | 4,535 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vld = vector<ld>;
using vvld = vector<vld>;
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
#define rep(i,start,end) for(ll i=start;i<(ll)(end);i++)
#define per(i,start,end) for(ll i=start;i>=(ll)(end);i--)
void solve(){
int h,w;
cin>>h>>w;
int x=((h+2)/3)*3,y=((w+2)/3)*3;
vvi ans(x,vi(y));
rep(i,0,x){
rep(j,0,y){
if(i%3==0&&j%3==0){
ans[i][j]=0;
}
else if(i%3>=1&&j%3>=1){
ans[i][j]=2;
}
else{
ans[i][j]=1;
}
}
}
int start_x=0,end_x=x,start_y=0,end_y=y;
if(h%3==1){
end_x-=2;
}
if(h%3==2){
start_x++;
}
if(w%3==1){
end_y-=2;
}
if(w%3==2){
start_y++;
}
rep(i,start_x,end_x){
rep(j,start_y,end_y){
cout<<ans[i][j]<<" ";
}
cout<<endl;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin>>t;
while(t--){
solve();
}
}
蜜蜂