結果
問題 | No.179 塗り分け |
ユーザー | weizen |
提出日時 | 2018-03-26 17:01:00 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,424 bytes |
コンパイル時間 | 848 ms |
コンパイル使用メモリ | 28,652 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-07 12:44:57 |
合計ジャッジ時間 | 3,030 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 4 ms
4,376 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 26 ms
4,376 KB |
testcase_09 | WA | - |
testcase_10 | AC | 2 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 22 ms
4,376 KB |
testcase_13 | AC | 2 ms
4,376 KB |
testcase_14 | AC | 2 ms
4,380 KB |
testcase_15 | AC | 1 ms
4,380 KB |
testcase_16 | AC | 1 ms
4,376 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 23 ms
4,380 KB |
testcase_21 | AC | 26 ms
4,380 KB |
testcase_22 | AC | 26 ms
4,380 KB |
testcase_23 | AC | 2 ms
4,376 KB |
testcase_24 | AC | 26 ms
4,380 KB |
testcase_25 | AC | 13 ms
4,380 KB |
testcase_26 | WA | - |
testcase_27 | AC | 26 ms
4,376 KB |
testcase_28 | WA | - |
testcase_29 | AC | 26 ms
4,376 KB |
testcase_30 | WA | - |
testcase_31 | AC | 26 ms
4,376 KB |
testcase_32 | AC | 11 ms
4,376 KB |
testcase_33 | AC | 26 ms
4,380 KB |
testcase_34 | WA | - |
testcase_35 | AC | 26 ms
4,376 KB |
testcase_36 | AC | 2 ms
4,376 KB |
testcase_37 | AC | 2 ms
4,376 KB |
testcase_38 | AC | 2 ms
4,376 KB |
testcase_39 | AC | 2 ms
4,376 KB |
testcase_40 | AC | 1 ms
4,376 KB |
testcase_41 | AC | 1 ms
4,376 KB |
testcase_42 | AC | 1 ms
4,376 KB |
testcase_43 | AC | 2 ms
4,380 KB |
testcase_44 | AC | 4 ms
4,380 KB |
testcase_45 | AC | 2 ms
4,380 KB |
ソースコード
#include <stdio.h> #include <string.h> #include <assert.h> int H, W; char str[100]; char board[100][100]; char shiftedboard[100][100]; char tmpboard[100][100]; void copyboard(char src[][100], char dst[][100]){ for(int x = 0; x < 100; x++){ for(int y = 0; y < 100; y++){ dst[x][y] = src[x][y]; } } } int countboard(char b[][100], int num){ int cnt=0; for(int x = 0; x < 2*W; x++){ for(int y = 0; y < 2*H; y++){ if(b[x][y]==num) cnt++; } } return cnt; } void printboard(char b[][100]){ /* for(int y=0; y < H; y++){ for(int x =0; x < W; x++){ printf("%d",b[x][y]); }puts(""); } puts("--"); */ } void shift(int shift_x, int shift_y){ assert(shift_x + W < 100 && shift_y + H < 100); memset(shiftedboard,0,sizeof(shiftedboard)); for(int x = 0; x < W; x++){ for(int y = 0; y < H; y++){ shiftedboard[x][y] += board[x][y]; shiftedboard[x+shift_x][y+shift_y] += board[x][y]; } } printboard(shiftedboard); } int main(void){ scanf("%d %d",&H,&W); memset(board,0,sizeof(board)); memset(tmpboard,0,sizeof(tmpboard)); for(int i = 0; i < H ; i++){ scanf("%s",str); for(int j = 0; j < W; j++){ board[j][i] = (str[j]=='#')? 1 : 0; } } int cnt_one = countboard(board, 1); printboard(board); int shift_x, shift_y; for(shift_x = 0; shift_x < W; shift_x++){ for(shift_y = 0; shift_y < H; shift_y++){ shift(shift_x,shift_y); //printf("count2=%d,cnt_one=%d\n",countboard(shiftedboard,2),cnt_one); if(countboard(shiftedboard,2) * 2 == cnt_one){ copyboard(board,tmpboard); for(int x = 0; x < W*2; x++){ for(int y = 0; y < H*2; y++){ if(shiftedboard[x][y]==2){ tmpboard[x-shift_x][y-shift_y] += 1; tmpboard[x][y] = 2; } } } //printf("candidate shiftx=%d shifty=%d\n",shift_x,shift_y); printboard(tmpboard); if(countboard(tmpboard,2) == cnt_one){ puts("YES"); return 0; } } } } puts("NO"); }