結果

問題 No.459 C-VS for yukicoder
ユーザー bal4ubal4u
提出日時 2019-08-17 16:56:28
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,907 bytes
コンパイル時間 1,089 ms
コンパイル使用メモリ 31,876 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-25 00:58:54
合計ジャッジ時間 3,948 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 4 ms
4,348 KB
testcase_22 AC 3 ms
4,348 KB
testcase_23 AC 4 ms
4,348 KB
testcase_24 AC 3 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 1 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 1 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 1 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 1 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 2 ms
4,348 KB
testcase_44 AC 1 ms
4,348 KB
testcase_45 AC 1 ms
4,348 KB
testcase_46 AC 1 ms
4,348 KB
testcase_47 AC 1 ms
4,348 KB
testcase_48 AC 2 ms
4,348 KB
testcase_49 AC 1 ms
4,348 KB
testcase_50 AC 2 ms
4,348 KB
testcase_51 AC 1 ms
4,348 KB
testcase_52 AC 1 ms
4,348 KB
testcase_53 AC 1 ms
4,348 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 1 ms
4,348 KB
testcase_56 AC 1 ms
4,348 KB
testcase_57 AC 2 ms
4,348 KB
testcase_58 AC 2 ms
4,348 KB
testcase_59 AC 1 ms
4,348 KB
testcase_60 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'in':
main.c:10:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
   10 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:18:24: note: in expansion of macro 'gc'
   18 |         int n = 0, c = gc();
      |                        ^~
main.c: In function 'outs':
main.c:11:15: warning: implicit declaration of function 'putchar_unlocked' [-Wimplicit-function-declaration]
   11 | #define pc(c) putchar_unlocked(c)
      |               ^~~~~~~~~~~~~~~~
main.c:30:33: note: in expansion of macro 'pc'
   30 | void outs(char *s) { while (*s) pc(*s++); pc('\n'); }
      |                                 ^~

ソースコード

diff #

// yukicoder: No.459 C-VS for yukicoder
// bal4u 2019.8.17

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//// 入出力関係
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() { // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void ins(char *s) { // 文字列の入力 スペース以下の文字で入力終了
	char *p = s;
	do *s = gc();
	while (*s++ > ' ');
	*--s = 0;
}

void outs(char *s) { while (*s) pc(*s++); pc('\n'); }

//// 本問題関連

char blk[3][4] = {"...", "...", "..."};
void out(char a) {
	int i; char h[3], b[3][4];
	memcpy(b, blk, sizeof(blk));
	h[0] = (a >> 4) & 3, h[1] = (a >> 2) & 3, h[2] = a & 3;
	for (i = 0; i < 3; i++)	while (h[i]) b[--h[i]][i] = '#';
	outs(b[2]), outs(b[1]), outs(b[0]);
}

int H, W;
int hi[10005];
int c[30005]; int N;
int f[10005];
char S[10005];
char *ans[10005]; int g[10005];

int main()
{
	int i, j, k, t, h[3];

	H = in(), W = in(), N = in();
	for (j = 0; j < H; j++) {
		ins(S);
		for (i = 0; i < W; i++) if (S[i] == '#') hi[i]++;
	}
	for (j = 0; j < N; j++) c[j] = in(), f[c[j]]++;

	for (i = 0; i < W; i++) if (f[i]) {
		ans[i] = malloc(f[i]);
		while (f[i]) {
			h[0] = h[1] = h[2] = 0, t = 0;
			for (j = 0; j < 3; j++) {
				k = i+j, t += f[k];
				if (hi[k = i+j] == 0) continue;
				if (t <= 1)             h[j] = hi[k];
				else if (hi[k] < t)     h[j] = 0;
				else if (hi[k] >= 3*t)  h[j] = 3;
				else if (hi[k] > 3*t-2) h[j] = 2;
				else                    h[j] = 1;
				hi[k] -= h[j];
			}
			
			if ((h[0] | h[1] | h[2]) == 0) {
				for (j = 0; j < 3; j++) if (hi[k = i+j]) {
					h[j] = 1, hi[k]--; break;
				}
			}
			ans[i][g[i]++] = (h[0]<<4) | (h[1]<<2) | h[2];
			f[i]--;
		}
	}
	
	for (i = 0; i < N; i++) k = c[i], out(ans[k][--g[k]]);
	return 0;
}
0