結果

問題 No.3171 Color Restoration
ユーザー pengin_2000
提出日時 2025-06-06 21:44:53
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,524 bytes
コンパイル時間 540 ms
コンパイル使用メモリ 25,344 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-06-06 21:44:55
合計ジャッジ時間 1,665 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:77:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   77 |                 scanf("%s", s[i]);
      |                 ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
int strcmp(char s[], char t[])
{
	int i;
	for (i = 0;; i++)
	{
		if (s[i] == '\0' && t[i] == '\0')
			return 0;
		if (t[i] == '\0')
			return 1;
		if (s[i] == '\0')
			return -1;
		if (s[i] > t[i])
			return 1;
		if (s[i] < t[i])
			return -1;
	}
}
char s[3][16];
char t[3][16][16] = {
	{"gray","brown","green","cyan","blue","yellow","orange","red"},
	{"gray","green","blue","yellow","red"},
	{"gray","green","cyan","blue","violet","orange","red" } };
char ans[3][16];
int cnt;
void check(int a, int b, int c)
{
	int f = 0;
	int i;
	for (i = 0; i < 8; i++)
		if (strcmp(s[a], t[0][i]) == 0)
			f++;
	if (f == 0)
		return;
	f = 0;
	for (i = 0; i < 5; i++)
		if (strcmp(s[b], t[1][i]) == 0)
			f++;
	if (f == 0)
		return;
	f = 0;
	for (i = 0; i < 7; i++)
		if (strcmp(s[c], t[2][i]) == 0)
			f++;
	if (f == 0)
		return;
	if (cnt == 0)
	{
		cnt++;
		for (i = 0; s[a][i] != '\0'; i++)
			ans[0][i] = s[a][i];
		ans[0][i] = '\0';
		for (i = 0; s[b][i] != '\0'; i++)
			ans[1][i] = s[b][i];
		ans[1][i] = '\0';
		for (i = 0; s[c][i] != '\0'; i++)
			ans[2][i] = s[c][i];
		ans[2][i] = '\0';
	}
	else
	{
		f = 0;
		if (strcmp(ans[0], s[a]) != 0)
			f++;
		if (strcmp(ans[1], s[b]) != 0)
			f++;
		if (strcmp(ans[2], s[c]) != 0)
			f++;
		if (f > 0)
			cnt++;
	}
}
int main()
{
	int i;
	for (i = 0; i < 3; i++)
		scanf("%s", s[i]);
	cnt = 0;
	check(0, 1, 2);
	check(0, 2, 1);
	check(1, 0, 2);
	check(1, 2, 0);
	check(2, 0, 1);
	check(2, 1, 0);
	if (cnt != 1)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}
0