結果

問題 No.24 数当てゲーム
ユーザー wakimiko01000010wakimiko01000010
提出日時 2019-04-11 11:36:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 796 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 65,144 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 11:12:12
合計ジャッジ時間 1,153 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n;
    int a[10][4];
    string s[10];
    int cnt[10] = {};
    int max = 0;
    int sub;
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3] >> s[i];
    }
    
    for (int i = 0; i < n; i++) {
        if (s[i] == "YES") {
            cnt[a[i][0]]++;
            cnt[a[i][1]]++;
            cnt[a[i][2]]++;
            cnt[a[i][3]]++;
        }
        else {
            cnt[a[i][0]]--;
            cnt[a[i][1]]--;
            cnt[a[i][2]]--;
            cnt[a[i][3]]--;
        }
    }
    
    for (int i = 0; i < 9; i++) {
        if (cnt[i] > max) {
            max = cnt[i];
            sub = i;
        }
    }
    
    cout << sub << endl;
}
0