QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#351991#5471. Interactive Number Guessingwarner1129#AC ✓1ms3692kbC++201.9kb2024-03-12 18:47:552024-03-12 18:47:56

Judging History

你现在查看的是最新测评结果

  • [2024-03-12 18:47:56]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3692kb
  • [2024-03-12 18:47:55]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

template <ranges::range T,
          class = enable_if_t<!is_convertible_v<T, string_view>>>
istream &operator>>(istream &s, T &&v) {
    for (auto &&x : v)
        s >> x;
    return s;
}
template <ranges::range T,
          class = enable_if_t<!is_convertible_v<T, string_view>>>
ostream &operator<<(ostream &s, T &&v) {
    for (auto &&x : v)
        s << x << ' ';
    return s;
}

#ifdef LOCAL
template <class... T> void dbg(T... x) {
    char e{};
    ((cerr << e << x, e = ' '), ...);
}
#define debug(x...) dbg(#x, '=', x, '\n')
#else
#define debug(...) ((void)0)
#endif

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second

template <class T> inline constexpr T inf = numeric_limits<T>::max() / 2;
template <class T> bool chmin(T &a, T b) { return (b < a and (a = b, true)); }
template <class T> bool chmax(T &a, T b) { return (a < b and (a = b, true)); }

using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i64 mod = 1e9 + 7;

void solve() {
    auto qry = [&](i64 a) -> i64 {
        cout << "query " << a << endl;
        i64 x;
        cin >> x;
        return x;
    };

    i64 base = qry(0);
    i64 ans = 0;
    i64 cur = 0;

    i64 pw = 1;
    
    while (cur < base) {
        int d = 0;
        for (int i = 8; i >= 1; i /= 2) {
            if (d + i < 10 and qry((d + i) * pw) > base) {
                d += i;
            }
        }
        d = 9 - d;
        debug(d);
        ans += pw * d;
        pw *= 10;
        cur += d;
    }

    cout << "answer " << ans << endl;
    
    
    
}

signed main() {
    cin.tie(0)->sync_with_stdio(false);
    cin.exceptions(cin.failbit);
    int T = 1;
    // cin >> T;
    while (T--)
        solve();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3564kb

input:

6
5
10
12
4
5
10
12
13
14
6

output:

query 0
query 8
query 4
query 6
query 7
query 80
query 40
query 60
query 70
query 800
query 900
answer 123

result:

ok correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

89
88
93
86
85
88
84
91
83
88
93
95
87
97
89
88
93
86
94
79
93
95
96
88
84
82
81
88
93
86
94
97
89
88
84
91
92
88
93
86
94
88
84
91
92
88
84
91
83
88
84
82
90
97
89
70
93
95
69
79
75
73
72
88
84
82
81

output:

query 0
query 8
query 4
query 6
query 5
query 80
query 40
query 20
query 30
query 800
query 400
query 600
query 700
query 8000
query 9000
query 80000
query 40000
query 60000
query 50000
query 800000
query 400000
query 600000
query 700000
query 8000000
query 4000000
query 2000000
query 1000000
query ...

result:

ok correct

Test #3:

score: 0
Accepted
time: 1ms
memory: 3564kb

input:

88
87
92
94
95
87
83
81
89
87
92
94
86
87
83
90
91
87
83
81
89
87
92
85
84
78
92
76
75
87
83
81
80
87
92
94
95
96
88
96
88
87
92
85
93
87
92
85
93
87
92
85
93
87
92
85
93
87
83
81
89
78
92
76
75
87
83
81
80

output:

query 0
query 8
query 4
query 6
query 7
query 80
query 40
query 20
query 10
query 800
query 400
query 600
query 700
query 8000
query 4000
query 2000
query 3000
query 80000
query 40000
query 20000
query 10000
query 800000
query 400000
query 600000
query 500000
query 8000000
query 4000000
query 600000...

result:

ok correct

Test #4:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

95
94
99
92
91
94
99
92
100
94
90
97
98
94
90
97
89
94
99
101
102
94
90
88
96
85
81
97
98
94
90
88
87
94
99
101
93
94
90
97
89
103
104
94
90
97
98
94
90
97
98
94
90
97
89
94
99
101
93
94
90
88
96
94
99
101
93
94
99
92
91

output:

query 0
query 8
query 4
query 6
query 5
query 80
query 40
query 60
query 50
query 800
query 400
query 200
query 300
query 8000
query 4000
query 2000
query 3000
query 80000
query 40000
query 60000
query 70000
query 800000
query 400000
query 200000
query 100000
query 8000000
query 4000000
query 200000...

result:

ok correct

Test #5:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

75
74
79
72
80
74
79
81
82
74
70
77
69
74
79
72
71
74
79
72
71
74
79
81
73
74
79
81
73
74
79
81
82
74
70
68
76
83
84
74
79
81
73
74
79
81
82
74
70
77
69
74
79
72
71
83
84
74
79
72
71
74
70
77
78
74
70
68
76

output:

query 0
query 8
query 4
query 6
query 5
query 80
query 40
query 60
query 70
query 800
query 400
query 200
query 300
query 8000
query 4000
query 6000
query 5000
query 80000
query 40000
query 60000
query 50000
query 800000
query 400000
query 600000
query 700000
query 8000000
query 4000000
query 600000...

result:

ok correct

Test #6:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

78
77
82
84
85
77
82
75
83
77
73
80
72
77
82
75
74
86
87
77
73
80
81
77
82
84
76
77
73
80
72
77
82
84
85
77
73
71
79
77
73
80
81
77
82
75
74
77
82
84
85
77
82
75
83
86
87
68
64
80
81
77
73
71
70
77
82
84
85

output:

query 0
query 8
query 4
query 6
query 7
query 80
query 40
query 60
query 50
query 800
query 400
query 200
query 300
query 8000
query 4000
query 6000
query 5000
query 80000
query 90000
query 800000
query 400000
query 200000
query 300000
query 8000000
query 4000000
query 6000000
query 7000000
query 80...

result:

ok correct

Test #7:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

62
61
57
64
56
61
66
59
67
61
66
59
67
70
71
61
66
59
58
61
57
64
65
61
57
64
65
70
62
70
62
70
62
70
71
61
66
68
60
61
66
68
69
61
66
68
60
52
66
68
69
61
57
55
54
61
66
59
67
61
66
59
67

output:

query 0
query 8
query 4
query 2
query 3
query 80
query 40
query 60
query 50
query 800
query 400
query 600
query 500
query 8000
query 9000
query 80000
query 40000
query 60000
query 50000
query 800000
query 400000
query 200000
query 300000
query 8000000
query 4000000
query 2000000
query 3000000
query ...

result:

ok correct

Test #8:

score: 0
Accepted
time: 1ms
memory: 3684kb

input:

46
54
55
45
50
52
53
54
55
36
50
34
51
45
41
39
38
54
46
45
50
52
44
54
55
54
37
45
41
39
38
54
46
45
50
52
53
45
41
48
49
45
50
52
53
54
55
45
50
52
44
45
50
52
44

output:

query 0
query 8
query 9
query 80
query 40
query 60
query 70
query 800
query 900
query 8000
query 4000
query 6000
query 5000
query 80000
query 40000
query 20000
query 10000
query 800000
query 900000
query 8000000
query 4000000
query 6000000
query 7000000
query 80000000
query 90000000
query 800000000
...

result:

ok correct

Test #9:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

89
88
93
95
87
88
93
95
87
88
84
91
83
88
93
95
96
88
84
91
92
88
84
91
92
88
93
95
87
88
84
82
90
97
89
88
93
95
96
88
93
95
96
88
84
91
92
88
84
91
83
88
84
82
90
88
84
91
92
88
84
91
83
88
93
86
94
88
84
82
90

output:

query 0
query 8
query 4
query 6
query 7
query 80
query 40
query 60
query 70
query 800
query 400
query 200
query 300
query 8000
query 4000
query 6000
query 7000
query 80000
query 40000
query 20000
query 30000
query 800000
query 400000
query 200000
query 300000
query 8000000
query 4000000
query 600000...

result:

ok correct

Test #10:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

63
71
72
62
67
69
61
62
67
69
70
62
67
69
70
62
67
60
68
71
45
53
49
47
46
62
58
56
55
62
58
56
64
71
72
62
58
65
66
62
67
69
61
71
63
62
67
69
61
62
58
65
57
71
63
71
63
62
67
69
61

output:

query 0
query 8
query 9
query 80
query 40
query 60
query 70
query 800
query 400
query 600
query 700
query 8000
query 4000
query 6000
query 7000
query 80000
query 40000
query 60000
query 50000
query 800000
query 900000
query 8000000
query 4000000
query 2000000
query 1000000
query 80000000
query 40000...

result:

ok correct

Test #11:

score: 0
Accepted
time: 1ms
memory: 3632kb

input:

84
83
88
90
82
83
88
81
89
83
88
90
91
65
61
86
87
74
70
68
67
83
79
77
76
83
79
77
85
83
88
90
91
92
93
92
93
83
79
77
76
83
88
81
89
83
79
86
78
83
88
90
82
74
88
90
73
83
79
77
76
83
79
86
87

output:

query 0
query 8
query 4
query 6
query 7
query 80
query 40
query 60
query 50
query 800
query 400
query 600
query 700
query 8000
query 4000
query 2000
query 3000
query 80000
query 40000
query 20000
query 10000
query 800000
query 400000
query 200000
query 100000
query 8000000
query 4000000
query 200000...

result:

ok correct

Test #12:

score: 0
Accepted
time: 1ms
memory: 3644kb

input:

0

output:

query 0
answer 0

result:

ok correct

Test #13:

score: 0
Accepted
time: 1ms
memory: 3684kb

input:

18
26
18
26
18
26
18
26
18
26
18
26
18
26
18
26
18
26
18
26
18
26
18
26
18
26
18
26
18
26
18
26
18
26
18
26
18

output:

query 0
query 8
query 9
query 80
query 90
query 800
query 900
query 8000
query 9000
query 80000
query 90000
query 800000
query 900000
query 8000000
query 9000000
query 80000000
query 90000000
query 800000000
query 900000000
query 8000000000
query 9000000000
query 80000000000
query 90000000000
query ...

result:

ok correct

Test #14:

score: 0
Accepted
time: 1ms
memory: 3692kb

input:

36
35
40
42
43
35
40
42
43
35
40
42
43
35
40
42
43
35
40
42
43
35
40
42
43
35
40
42
43
35
40
42
43
35
40
42
43
35
40
42
43
35
40
42
43
35
40
42
43
35
40
42
43
35
40
42
43
35
40
42
43
35
40
42
43
35
40
42
43
35
40
42
43

output:

query 0
query 8
query 4
query 6
query 7
query 80
query 40
query 60
query 70
query 800
query 400
query 600
query 700
query 8000
query 4000
query 6000
query 7000
query 80000
query 40000
query 60000
query 70000
query 800000
query 400000
query 600000
query 700000
query 8000000
query 4000000
query 600000...

result:

ok correct

Test #15:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

54
53
58
60
52
53
58
60
52
53
58
60
52
53
58
60
52
53
58
60
52
53
58
60
52
53
58
60
52
53
58
60
52
53
58
60
52
53
58
60
52
53
58
60
52
53
58
60
52
53
58
60
52
53
58
60
52
53
58
60
52
53
58
60
52
53
58
60
52
53
58
60
52

output:

query 0
query 8
query 4
query 6
query 7
query 80
query 40
query 60
query 70
query 800
query 400
query 600
query 700
query 8000
query 4000
query 6000
query 7000
query 80000
query 40000
query 60000
query 70000
query 800000
query 400000
query 600000
query 700000
query 8000000
query 4000000
query 600000...

result:

ok correct

Test #16:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

72
71
76
69
77
71
76
69
77
71
76
69
77
71
76
69
77
71
76
69
77
71
76
69
77
71
76
69
77
71
76
69
77
71
76
69
77
71
76
69
77
71
76
69
77
71
76
69
77
71
76
69
77
71
76
69
77
71
76
69
77
71
76
69
77
71
76
69
77
71
76
69
77

output:

query 0
query 8
query 4
query 6
query 5
query 80
query 40
query 60
query 50
query 800
query 400
query 600
query 500
query 8000
query 4000
query 6000
query 5000
query 80000
query 40000
query 60000
query 50000
query 800000
query 400000
query 600000
query 500000
query 8000000
query 4000000
query 600000...

result:

ok correct

Test #17:

score: 0
Accepted
time: 1ms
memory: 3572kb

input:

90
89
94
87
86
89
94
87
86
89
94
87
86
89
94
87
86
89
94
87
86
89
94
87
86
89
94
87
86
89
94
87
86
89
94
87
86
89
94
87
86
89
94
87
86
89
94
87
86
89
94
87
86
89
94
87
86
89
94
87
86
89
94
87
86
89
94
87
86
89
94
87
86

output:

query 0
query 8
query 4
query 6
query 5
query 80
query 40
query 60
query 50
query 800
query 400
query 600
query 500
query 8000
query 4000
query 6000
query 5000
query 80000
query 40000
query 60000
query 50000
query 800000
query 400000
query 600000
query 500000
query 8000000
query 4000000
query 600000...

result:

ok correct

Test #18:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

108
107
103
110
111
107
103
110
111
107
103
110
111
107
103
110
111
107
103
110
111
107
103
110
111
107
103
110
111
107
103
110
111
107
103
110
111
107
103
110
111
107
103
110
111
107
103
110
111
107
103
110
111
107
103
110
111
107
103
110
111
107
103
110
111
107
103
110
111
107
103
110
111

output:

query 0
query 8
query 4
query 2
query 3
query 80
query 40
query 20
query 30
query 800
query 400
query 200
query 300
query 8000
query 4000
query 2000
query 3000
query 80000
query 40000
query 20000
query 30000
query 800000
query 400000
query 200000
query 300000
query 8000000
query 4000000
query 200000...

result:

ok correct

Test #19:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

126
125
121
128
120
125
121
128
120
125
121
128
120
125
121
128
120
125
121
128
120
125
121
128
120
125
121
128
120
125
121
128
120
125
121
128
120
125
121
128
120
125
121
128
120
125
121
128
120
125
121
128
120
125
121
128
120
125
121
128
120
125
121
128
120
125
121
128
120
125
121
128
120

output:

query 0
query 8
query 4
query 2
query 3
query 80
query 40
query 20
query 30
query 800
query 400
query 200
query 300
query 8000
query 4000
query 2000
query 3000
query 80000
query 40000
query 20000
query 30000
query 800000
query 400000
query 200000
query 300000
query 8000000
query 4000000
query 200000...

result:

ok correct

Test #20:

score: 0
Accepted
time: 1ms
memory: 3688kb

input:

144
143
139
137
145
143
139
137
145
143
139
137
145
143
139
137
145
143
139
137
145
143
139
137
145
143
139
137
145
143
139
137
145
143
139
137
145
143
139
137
145
143
139
137
145
143
139
137
145
143
139
137
145
143
139
137
145
143
139
137
145
143
139
137
145
143
139
137
145
143
139
137
145

output:

query 0
query 8
query 4
query 2
query 1
query 80
query 40
query 20
query 10
query 800
query 400
query 200
query 100
query 8000
query 4000
query 2000
query 1000
query 80000
query 40000
query 20000
query 10000
query 800000
query 400000
query 200000
query 100000
query 8000000
query 4000000
query 200000...

result:

ok correct

Test #21:

score: 0
Accepted
time: 1ms
memory: 3632kb

input:

162
8
4
2
1
17
13
11
10
26
22
20
19
35
31
29
28
44
40
38
37
53
49
47
46
62
58
56
55
71
67
65
64
80
76
74
73
89
85
83
82
98
94
92
91
107
103
101
100
116
112
110
109
125
121
119
118
134
130
128
127
143
139
137
136
152
148
146
145
161
157
155
154

output:

query 0
query 8
query 4
query 2
query 1
query 80
query 40
query 20
query 10
query 800
query 400
query 200
query 100
query 8000
query 4000
query 2000
query 1000
query 80000
query 40000
query 20000
query 10000
query 800000
query 400000
query 200000
query 100000
query 8000000
query 4000000
query 200000...

result:

ok correct

Test #22:

score: 0
Accepted
time: 1ms
memory: 3568kb

input:

10
9
14
7
6
9
14
7
6

output:

query 0
query 8
query 4
query 6
query 5
query 80
query 40
query 60
query 50
answer 55

result:

ok correct

Test #23:

score: 0
Accepted
time: 1ms
memory: 3560kb

input:

15
5
1
17
18
14
10
8
7

output:

query 0
query 8
query 4
query 2
query 3
query 80
query 40
query 20
query 10
answer 96

result:

ok correct

Test #24:

score: 0
Accepted
time: 1ms
memory: 3568kb

input:

4
3
8
10
11
3
8
10
11

output:

query 0
query 8
query 4
query 6
query 7
query 80
query 40
query 60
query 70
answer 22

result:

ok correct

Test #25:

score: 0
Accepted
time: 1ms
memory: 3572kb

input:

9
8
4
11
3
8
13
15
16

output:

query 0
query 8
query 4
query 2
query 3
query 80
query 40
query 60
query 70
answer 27

result:

ok correct

Test #26:

score: 0
Accepted
time: 1ms
memory: 3572kb

input:

10
9
14
16
17
9
5
3
11

output:

query 0
query 8
query 4
query 6
query 7
query 80
query 40
query 20
query 10
answer 82

result:

ok correct