結果

問題 No.313 π
コンテスト
ユーザー xyz600600
提出日時 2016-02-14 10:07:15
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 4 ms / 5,000 ms
+ 163µs
コード長 602 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 332 ms
コンパイル使用メモリ 82,524 KB
実行使用メモリ 9,792 KB
最終ジャッジ日時 2026-09-02 06:05:45
合計ジャッジ時間 2,325 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:23:7: warning: 'a' is used uninitialized [-Wuninitialized]
   23 |   int a, b;
      |       ^
main.cpp:23:10: warning: 'b' is used uninitialized [-Wuninitialized]
   23 |   int a, b;
      |          ^

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  vector<int> hist_ans = {20104, 20063, 19892, 20011, 19874, 20199, 19898, 20163, 19956, 19841};

  vector<int> hist_in( 10 );
  fill( hist_in.begin(), hist_in.end(), 0 );
  string line;
  getline( cin, line );
  for ( char ch : line )
  {
	if ( '0' <= ch && ch <= '9' )
	{
	  hist_in[ ch - '0' ]++;
	}
  }

  int a, b;
  for ( int i = 0; i <= 9; i++ )
  {
	if ( hist_ans[ i ] < hist_in[ i ] )
	{
	  a = i;
	}
	else if ( hist_ans[ i ] > hist_in[ i ] )
	{
	  b = i;
	}
  }
  cout << a << " " << b << endl;
}
0