結果

問題 No.24 数当てゲーム
ユーザー MATSUMATMATSUMAT
提出日時 2018-10-07 22:31:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 633 bytes
コンパイル時間 1,722 ms
コンパイル使用メモリ 173,068 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 18:20:50
合計ジャッジ時間 2,267 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/istream:41,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/sstream:40,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/complex:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/ccomplex:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/x86_64-pc-linux-gnu/bits/stdc++.h:127,
                 from main.cpp:1:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]',
    inlined from 'int main()' at main.cpp:38:11:
/home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/ostream:204:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
  204 |       { return _M_insert(__n); }
      |                ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:4:15: note: 'ans' was declared here
    4 |   long long n,ans,MAX=-1;
      |               ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans,MAX=-1;
  string s;
  cin >> n;
  bool f[10];
  map<long long,int> mp;
  for(int i=0;i<10;i++){
    f[i]=true;
  }
  long long a[4];
  for(int i=0;i<n;i++){
    for(int j=0;j<4;j++){
      cin >> a[j];
    }
    cin >> s;
    if(s=="NO"){
      for(int j=0;j<4;j++){
        f[a[j]]=false;
      }
    }else{
      for(int j=0;j<4;j++){
        if(f[a[j]]){
          mp[a[j]]++;
        }
      }
    }
  }
  for(int i=0;i<10;i++){
    if(f[i]){
      if(MAX<mp[i]){
        ans=i;
        MAX=mp[i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}
0