結果

問題 No.24 数当てゲーム
ユーザー nnasennnasen
提出日時 2017-08-28 05:37:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 451 bytes
コンパイル時間 1,492 ms
コンパイル使用メモリ 164,720 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-24 01:06:03
合計ジャッジ時間 2,020 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:26:17: warning: 'index' may be used uninitialized [-Wmaybe-uninitialized]
   26 |         cout << index << endl;
      |                 ^~~~~
main.cpp:19:13: note: 'index' was declared here
   19 |         int index, ans = 0;
      |             ^~~~~

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
using namespace std;

int main() {
	int n, a, b, c, d;
	string r;
	int x[10] = { 0 };
	cin >> n;
	FOR(i, 0, n) {
		cin >> a >> b >> c >> d >> r;
		if (r == "YES") {
			x[a]++; x[b]++; x[c]++; x[d]++;
		}
		else {
			x[a] = x[b] = x[c] = x[d] = -n;
		}
	}
	int index, ans = 0;
	FOR(i, 0, 10) {
		if (x[i] >= ans) {
			ans = x[i];
			index = i;
		}
	}
	cout << index << endl;

}
0