結果

問題 No.446 ゆきこーだーの雨と雪 (1)
ユーザー bal4u
提出日時 2019-04-20 22:37:33
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 824 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 30,336 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-02 08:02:10
合計ジャッジ時間 878 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'ins':
main.c:8:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
    8 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:18:17: note: in expansion of macro 'gc'
   18 |         do *s = gc();
      |                 ^~
main.c: In function 'outs':
main.c:9:15: warning: implicit declaration of function 'putchar_unlocked' [-Wimplicit-function-declaration]
    9 | #define pc(c) putchar_unlocked(c)
      |               ^~~~~~~~~~~~~~~~
main.c:24:33: note: in expansion of macro 'pc'
   24 | void outs(char *s) { while (*s) pc(*s++); }
      |                                 ^~

ソースコード

diff #

// yukicoder: No.446 ゆきこーだーの雨と雪 (1)
// 2019.4.20 bal4u

#include <stdio.h>
#include <ctype.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

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

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

int main()
{
	int i, j, w, k;
	char s[20];

	for (j = 0; j < 2; j++) {
		w = ins(s);
		if (w == 1) {
			if (!isdigit(s[0])) goto NG;
		} else {
			k = 0; for (i = 0; i < w; i++) {
				if (!isdigit(s[i]) || (i != w-1) && s[i] == '0') goto NG;
				k = 10*k + (s[i]&0xf);
			}
			if (k > 12345) goto NG;
		}
	}
	outs("OK\n");
	return 0;
NG: outs("NG\n");
	return 0;
}
0