結果
| 問題 |
No.1851 Regular Tiling
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-25 22:51:55 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 2,000 ms |
| コード長 | 1,159 bytes |
| コンパイル時間 | 318 ms |
| コンパイル使用メモリ | 29,056 KB |
| 最終ジャッジ日時 | 2025-01-28 02:20:51 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%d", &testcase_i);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d %d", &H, &W);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
int testcase_i;
scanf("%d", &testcase_i);
for (int ___ = 0; ___ < testcase_i; ___++){
int H, W;
scanf("%d %d", &H, &W);
char pattern[3][3];
if(H%3 == 1){
if(W%3 == 1){
char tmp[3][3] = {{'0','1','1'},{'1','2','2'},{'1','2','2'}};
rep(i,3) rep(j,3) pattern[i][j] = tmp[i][j];
}else{
char tmp[3][3] = {{'1','1','0'},{'2','2','1'},{'2','2','1'}};
rep(i,3) rep(j,3) pattern[i][j] = tmp[i][j];
}
}else if(W%3 == 1){
char tmp[3][3] = {{'1','2','2'},{'1','2','2'},{'0','1','1'}};
rep(i,3) rep(j,3) pattern[i][j] = tmp[i][j];
}else{
char tmp[3][3] = {{'2','2','1'},{'2','2','1'},{'1','1','0'}};
rep(i,3) rep(j,3) pattern[i][j] = tmp[i][j];
}
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
{
printf("%c", pattern[i%3][j%3]);
printf(j < W-1 ? " " : "\n");
}
}
}
}