結果

問題 No.305 鍵(2)
ユーザー utouto97utouto97
提出日時 2019-02-28 14:56:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 2,049 bytes
コンパイル時間 1,384 ms
コンパイル使用メモリ 149,652 KB
実行使用メモリ 24,348 KB
平均クエリ数 54.77
最終ジャッジ日時 2023-09-24 02:07:03
合計ジャッジ時間 2,905 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,628 KB
testcase_01 AC 28 ms
23,628 KB
testcase_02 AC 26 ms
23,688 KB
testcase_03 AC 27 ms
23,400 KB
testcase_04 AC 26 ms
24,348 KB
testcase_05 AC 25 ms
24,300 KB
testcase_06 AC 24 ms
23,664 KB
testcase_07 AC 25 ms
23,664 KB
testcase_08 AC 27 ms
24,060 KB
testcase_09 AC 26 ms
24,300 KB
testcase_10 AC 26 ms
23,520 KB
testcase_11 AC 27 ms
23,688 KB
testcase_12 AC 28 ms
23,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:80:10: warning: ‘y’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     ans[y] = '0';
          ^
main.cpp:87:13: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             if(x != k) t += '1';
             ^~

ソースコード

diff #

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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

int ask(string s)
{
  cout << s << endl;

  int x;
  cin >> x >> s;
  return x;
}

int main()
{
  int ret;
  string ans = "0123456789";
  vi cnt(10);
  int zero = -1;
  rep(i, 10){
    string t;
    rep(j, 10) t += (i+'0');
    ret = ask(t);
    if(ret == 10) return 0;
    if(ret == 0) zero = i;
    cnt[i] = ret;
  }

  if(zero == -1){
    int x, y;
    rep(i, 10){
      string t;
      rep(j, 10){
        if(i == j) t += '1';
        else t += '0';
      }
      ret = ask(t);
      if(ret == 10) return 0;
      if(ret == 2) x = i;
    }
    rep(i, 10){
      string t;
      rep(j, 10){
        if(i == j) t += '0';
        else t += '1';
      }
      ret = ask(t);
      if(ret == 10) return 0;
      if(ret == 2) y = i;
    }
    ans[x] = '1';
    ans[y] = '0';
    repi(i, 2, 10){
      rep(j, 10){
        string t;
        rep(k, 10){
          if(j == k) t += (i+'0');
          else{
            if(x != k) t += '1';
            else t += '0';
          }
        }
        ret = ask(t);
        if(ret == 10) return 0;
        if(ret) ans[j] = i+'0';
      }
    }
  }else{
    rep(i, 10) if(cnt[i]){
      rep(j, 10){
        string t;
        rep(k, 10){
          if(j == k) t += (i+'0');
          else t += (zero+'0');
        }
        ret = ask(t);
        if(ret == 10) return 0;
        if(ret) ans[j] = i+'0';
      }
    }
  }

  cout << ans << endl;
  
  return 0;
}
0