結果

問題 No.349 干支の置き物
ユーザー FF256grhy
提出日時 2016-03-24 15:39:11
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 22,912 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-17 07:28:35
合計ジャッジ時間 1,103 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
main.cpp:18:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         for(i = 0; i < n; i++) { scanf("%s", s[i]); }
      |                                  ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int n;
char s[50][8];

int eq(int a, int b) {
	int i = 0;
	while(s[a][i] == s[b][i]) {
		if(s[a][i] == '\0') { return 1; }
		i++;
	}
	return 0;
}

int main(void) {
	scanf("%d", &n);
	int i, j;
	for(i = 0; i < n; i++) { scanf("%s", s[i]); }
	
	int flag = 1;
	for(i = 0; i < n; i++) {
		int c = 0;
		for(j = 0; j < n; j++) {
			c += eq(i, j);
		}
		if(c > (n + 1) / 2) { flag = 0; }
	}
	
	printf("%s\n", flag ? "YES" : "NO");
	
	return 0;
}
0