結果

問題 No.24 数当てゲーム
ユーザー byamibyami
提出日時 2017-11-05 14:34:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 551 bytes
コンパイル時間 1,368 ms
コンパイル使用メモリ 164,548 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-15 18:43:34
合計ジャッジ時間 2,027 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:26:13: 警告: ‘index’ may be used uninitialized [-Wmaybe-uninitialized]
   26 |     cout << index << endl;
      |             ^~~~~
main.cpp:19:9: 備考: ‘index’ はここで定義されています
   19 |     int index, ans = 0;
      |         ^~~~~

ソースコード

diff #

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

int main(){
    int n, a, b, c, d;
    string r;
    int x[10] = { 0 };
    cin >> n;
    rep(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;
    rep(i, 0, 10) {
        if (x[i] >= ans) {
            ans = x[i];
            index = i;
        }
    }
    cout << index << endl;
}
0