結果

問題 No.3196 Unique Nickname
ユーザー pengin_2000
提出日時 2025-07-11 21:29:16
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 877 bytes
コンパイル時間 934 ms
コンパイル使用メモリ 26,700 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-07-11 21:29:47
合計ジャッジ時間 1,307 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:23:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:26:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |                 scanf("%s%s", s[i][0], s[i][1]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

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[102][2][32];
int main()
{
	int n;
	scanf("%d", &n);
	int i, j, k;
	for (i = 0; i < n; i++)
		scanf("%s%s", s[i][0], s[i][1]);
	for (i = 0; i < n; i++)
	{
		k = 0;
		for (j = 0; j < n; j++)
		{
			if (i == j)
				continue;
			if (strcmp(s[i][0], s[j][0]) == 0)
				k++;
			if (strcmp(s[i][0], s[j][1]) == 0)
				k++;
		}
		if (k == 0)
			continue;
		k = 0;
		for (j = 0; j < n; j++)
		{
			if (i == j)
				continue;
			if (strcmp(s[i][1], s[j][0]) == 0)
				k++;
			if (strcmp(s[i][1], s[j][1]) == 0)
				k++;
		}
		if (k == 0)
			continue;
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}
0