結果

問題 No.548 国士無双
コンテスト
ユーザー subsn
提出日時 2023-06-19 13:30:58
言語 C11(gcc12 gnu拡張)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=gnu11 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 443 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 89 ms
コンパイル使用メモリ 29,380 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-08 16:35:01
合計ジャッジ時間 637 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: implicit declaration of function ‘memset’ [-Wimplicit-function-declaration]
    7 |         memset(c, 0, sizeof(int) * 26);
      |         ^~~~~~
main.c:1:1: note: include ‘<string.h>’ or provide a declaration of ‘memset’
  +++ |+#include <string.h>
    1 | 
main.c:7:9: warning: incompatible implicit declaration of built-in function ‘memset’ [-Wbuiltin-declaration-mismatch]
    7 |         memset(c, 0, sizeof(int) * 26);
      |         ^~~~~~
main.c:7:9: note: include ‘<string.h>’ or provide a declaration of ‘memset’
main.c:8:9: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
    8 |         scanf("%s",&s);
      |         ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
  +++ |+#include <stdio.h>
    1 | 
main.c:8:9: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
    8 |         scanf("%s",&s);
      |         ^~~~~
main.c:8:9: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
main.c:8:17: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[14]’ [-Wformat=]
    8 |         scanf("%s",&s);
      |                ~^  ~~
      |                 |  |
      |                 |  char (*)[14]
      |                 char *
main.c:15:33: warning: implicit declaration of function ‘puts’ [-Wimplicit-function-declaration]
   15 |                                 puts("Impossible");
      |                                 ^~~~
main.c:15:33: note: include ‘<stdio.h>’ or provide a declaration of ‘puts’
main.c:25:25: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
   25 |                         printf("%c\n",i+97);
      |                         ^~~~~~
main.c:25:25: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c

ソースコード

diff #
raw source code

int main()
{
	char s[14];
	int c[26];
	int f = 0;
	memset(c, 0, sizeof(int) * 26);
	scanf("%s",&s);
	for (int i = 0;i < 13;i++) {
		c[(int)s[i] - 97]++;
	}
	for (int i = 0;i < 13;i++) {
		if (c[i] == 0) {
			if (f) {
				puts("Impossible");
				return 0;
			}
			else {
				f++;
			}
		}
	}
	for (int i = 0;i < 13;i++) {
		if (c[i] == 0) {
			printf("%c\n",i+97);
			return 0;
		}
	}
	for (int i = 0;i < 13;i++) {
		printf("%c\n",i+97);
	}
}
0