結果

問題 No.355 数当てゲーム(2)
ユーザー 0w1
提出日時 2016-11-27 19:35:13
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 1,241 bytes
コンパイル時間 1,826 ms
コンパイル使用メモリ 179,712 KB
実行使用メモリ 25,464 KB
平均クエリ数 5.52
最終ジャッジ日時 2024-07-17 00:39:06
合計ジャッジ時間 6,173 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

signed main(){
  set< tuple< int, int, int, int > > cand;
  for( int i = 0; i < 10; ++i )
    for( int j = 0; j < 10; ++j ) if( j != i )
      for( int k = 0; k < 10; ++k ) if( k != i and k != j )
        for( int l = 0; l < 10; ++l ) if( l != i and l != j and l != k )
          cand.emplace( i, j, k, l );
  while( not cand.empty() ){
    int a, b, c, d; tie( a, b, c, d ) = *cand.begin();
    cout << a << " " << b << " " << c << " " << d << endl;
    int x, y; cin >> x >> y; // exactly same / different pos but has
    if( x == 4 and y == 0 )
      exit( 0 );
    set< tuple< int, int, int, int > > ncand;
    for( auto it = cand.begin(); it != cand.end(); ++it ){
      int sx = 0, sy = 0;
      int e, f, g, h; tie( e, f, g, h ) = *it;
      sx = ( a == e ) + ( b == f ) + ( c == g ) + ( d == h );
      if( a != e and ( a == f or a == g or a == h ) )
        ++sy;
      if( b != f and ( b == e or b == g or b == h ) )
        ++sy;
      if( c != g and ( c == e or c == f or c == h ) )
        ++sy;
      if( d != h and ( d == e or d == f or d == g ) )
        ++sy;
      if( sx == x and sy == y )
        ncand.emplace( e, f, g, h );
    }
    swap( cand, ncand );
  }
  return 0;
}
0