結果

問題 No.459 C-VS for yukicoder
ユーザー bal4ubal4u
提出日時 2019-08-17 12:00:46
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 1,651 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 31,904 KB
実行使用メモリ 813,052 KB
最終ジャッジ日時 2023-10-25 00:06:27
合計ジャッジ時間 5,864 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,348 KB
testcase_21 RE -
testcase_22 AC 4 ms
4,348 KB
testcase_23 MLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'in':
main.c:9:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
    9 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:17:24: note: in expansion of macro 'gc'
   17 |         int n = 0, c = gc();
      |                        ^~
main.c: In function 'outs':
main.c:10:15: warning: implicit declaration of function 'putchar_unlocked' [-Wimplicit-function-declaration]
   10 | #define pc(c) putchar_unlocked(c)
      |               ^~~~~~~~~~~~~~~~
main.c:29:33: note: in expansion of macro 'pc'
   29 | 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 <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(int *h) {
	int i; char b[3][4];
	memcpy(b, blk, sizeof(blk));
	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[30005];
char S[10005];

int main()
{
	int i, j, k, 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();
		for (i = 0; i < 3; i++) f[c[j]+i]++;
	}
	
	for (j = 0; j < N; j++) {
		for (i = 0; i < 3; i++) {
			k = c[j]+i;
			if (f[k] == 1) h[i] = hi[k];
			else {
				if (hi[k] < f[k]) h[i] = 0;
				else if (hi[k] == 3*f[k]) h[i] = 3;
				else h[i] = 1;
			}
			hi[k] -= h[i];
			f[k]--;
		}
		if ((h[0] | h[1] | h[2]) == 0) {
			for (i = 0; i < 3; i++) if (hi[c[j]+i]) { k = i; break; }
			for (i = 0; i < 3; i++) if (k != i && hi[c[j]+i]) {
				if (f[c[j]+k]*hi[c[j]+i] > f[c[j]+i]*hi[c[j]+k]) k = i;
			}
			h[k] = 1, hi[c[j]+k]--;
		}
		out(h);
	}
	return 0;
}
0