Submission #1427330


Source Code Expand

#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

bool flush(ll n) {
  assert(1 <= n && n <= 1000000000000000000);
  cout << "? " << n << endl;
  char c;
  cin >> c;
  return (c == 'Y');
}

void answer(ll n) {
  assert(1 <= n && n <= 1000000000);
  cout << "! " << n << endl;
}

int main () {
  ll N = 0;
  while (N < 1000000000) {
    int ub = 9;
    int lb = ((N == 0) ? 0 : -1);
    while (ub - lb > 1) {
      int t = (ub + lb)/2;
      string str = to_string(N) + to_string(t);
      while (stoll(str) <= 1000000000) {
        str = str + "9";
      }
      ll now = stoll(str);
      if (flush(now)) {
        ub = t;
      } else {
        lb = t;
      }
    }
    N = stoll(to_string(N) + to_string(ub));
  }
  while (N % 10 == 0) {
    if (flush(N/10 + 1)) {
      N = N/10;
    } else {
      break;
    }
  }
  answer(N);
}

Submission Info

Submission Time
Task E - Awkward Response
User kazunetakahashi
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1811 Byte
Status WA
Exec Time 100 ms
Memory 596 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 800
Status
AC × 1
AC × 31
WA × 9
Set Name Test Cases
Sample 00_example_01.txt
All 00_example_01.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 4 ms 592 KB
01.txt AC 4 ms 592 KB
02.txt AC 4 ms 596 KB
03.txt AC 4 ms 592 KB
04.txt AC 4 ms 592 KB
05.txt AC 4 ms 592 KB
06.txt AC 4 ms 592 KB
07.txt AC 4 ms 592 KB
08.txt AC 4 ms 588 KB
09.txt AC 4 ms 592 KB
10.txt AC 4 ms 592 KB
11.txt AC 4 ms 588 KB
12.txt AC 4 ms 588 KB
13.txt AC 4 ms 588 KB
14.txt AC 4 ms 588 KB
15.txt AC 4 ms 592 KB
16.txt AC 4 ms 596 KB
17.txt AC 4 ms 592 KB
18.txt AC 4 ms 596 KB
19.txt AC 4 ms 592 KB
20.txt AC 4 ms 596 KB
21.txt AC 4 ms 596 KB
22.txt AC 4 ms 592 KB
23.txt AC 4 ms 592 KB
24.txt AC 4 ms 596 KB
25.txt AC 4 ms 592 KB
26.txt AC 4 ms 592 KB
27.txt AC 4 ms 596 KB
28.txt AC 4 ms 592 KB
29.txt AC 4 ms 596 KB
30.txt AC 4 ms 592 KB
31.txt WA 4 ms 592 KB
32.txt WA 4 ms 588 KB
33.txt WA 4 ms 596 KB
34.txt WA 4 ms 588 KB
35.txt WA 4 ms 596 KB
36.txt WA 4 ms 588 KB
37.txt WA 4 ms 592 KB
38.txt WA 4 ms 592 KB
39.txt WA 100 ms 592 KB