QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#707132#9537. Chinese Chessucup-team5243AC ✓4ms4252kbC++1712.0kb2024-11-03 14:47:462024-11-03 14:47:46

Judging History

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

  • [2024-11-03 14:47:46]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:4252kb
  • [2024-11-03 14:47:46]
  • 提交

answer

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<int(n); i++)
const i64 INF = 1001001001001001001;
template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; }
template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; }
using namespace std;

#include <iterator>
#include <functional>
#include <utility>
#include <type_traits>

template<class Elem> struct vec;

template<class Iter>
struct seq_view{
    using Ref = typename std::iterator_traits<Iter>::reference;
    using Elem = typename std::iterator_traits<Iter>::value_type;
    Iter a, b;
    Iter begin() const { return a; }
    Iter end() const { return b; }
    int size() const { return (int)(b-a); }
    seq_view(Iter first, Iter last) : a(first), b(last) {}
    seq_view sort() const { std::sort(a, b); return *this; }
    Ref& operator[](int x) const { return *(a+x); }
    template<class F = std::less<Elem>, class ret = vec<int>> ret sorti(F f = F()) const {
        ret x(size()); for(int i=0; i<size(); i++) x[i] = i;
        x().sort([&](int l, int r){ return f(a[l],a[r]); });
        return x;
    }
    template<class ret = vec<Elem>> ret col() const { return ret(begin(), end()); }
    template<class ret = vec<Elem>> ret cumsum() const {
        auto res = ret(size() + 1, Elem(0));
        for(int i=0; i<size(); i++) res[i+1] = res[i] + operator[](i);
        return res;
    }
    template<class F = std::equal_to<Elem>, class ret = vec<std::pair<Elem, int>>>
    ret rle(F eq = F()) const {
        auto x = ret();
        for(auto& a : (*this)){
            if(x.size() == 0 || !eq(x[x.size()-1].first, a)) x.emp(a, 1); else x[x.size()-1].second++;
        } return x;
    }
    template<class F> seq_view sort(F f) const { std::sort(a, b, f); return *this; }
    Iter uni() const { return std::unique(a, b); }
    Iter lb(const Elem& x) const { return std::lower_bound(a, b, x); }
    Iter ub(const Elem& x) const { return std::upper_bound(a, b, x); }
    int lbi(const Elem& x) const { return lb(x) - a; }
    int ubi(const Elem& x) const { return ub(x) - a; }
    seq_view bound(const Elem& l, const Elem& r) const { return { lb(l), lb(r) }; }
    template<class F> Iter lb(const Elem& x, F f) const { return std::lower_bound(a, b, x, f); }
    template<class F> Iter ub(const Elem& x, F f) const { return std::upper_bound(a, b, x, f); }
    template<class F> Iter when_true_to_false(F f) const {
        if(a == b) return a;
        return std::lower_bound(a, b, *a,
            [&](const Elem& x, const Elem&){ return f(x); });
    }
    seq_view same(Elem x) const { return { lb(x), ub(x) }; }
    template<class F> auto map(F f) const {
        vec<decltype(f(std::declval<const typename Iter::value_type&>()))> r;
        for(auto& x : *this) r.emp(f(x));
        return r;
    }
    Iter max() const { return std::max_element(a, b); }
    Iter min() const { return std::min_element(a, b); }
    template<class F = std::less<Elem>>
    Iter min(F f) const { return std::min_element(a, b, f); }
    seq_view rev() const { std::reverse(a, b); return *this; }
};

template<class Elem>
struct vec {
public:
    using Base = typename std::vector<Elem>;
    using Iter = typename Base::iterator;
    using CIter = typename Base::const_iterator;
    using View = seq_view<Iter>;
    using CView = seq_view<CIter>;

    vec(){}
    explicit vec(int n, const Elem& value = Elem()) : a(0<n?n:0, value) {}
    template <class I2> vec(I2 first, I2 last) : a(first, last) {}
    vec(std::initializer_list<Elem> il) : a(std::move(il)) {}
    vec(Base b) : a(std::move(b)) {}
    operator Base() const { return a; }

    Iter begin(){ return a.begin(); }
    CIter begin() const { return a.begin(); }
    Iter end(){ return a.end(); }
    CIter end() const { return a.end(); }
    int size() const { return a.size(); }
    bool empty() const { return a.empty(); }
    Elem& back(){ return a.back(); }
    const Elem& back() const { return a.back(); }
    vec& sortuni(){ (*this)().sort(); a.erase((*this)().uni(), end()); return *this; }
    vec sortunied(){ vec x = *this; x.sortuni(); return x; }
    Iter operator()(int x){ return a.begin() + x; }
    CIter operator()(int x) const { return a.begin() + x; }
    View operator()(int l, int r){ return { (*this)(l), (*this)(r) }; }
    CView operator()(int l, int r) const { return { (*this)(l), (*this)(r) }; }
    View operator()(){ return (*this)(0,size()); }
    CView operator()() const { return (*this)(0,size()); }
    Elem& operator[](int x){ return a[x]; }
    const Elem& operator[](int x) const { return a[x]; }
    Base& operator*(){ return a; }
    const Base& operator*() const { return a; }
    vec& push(Elem args){
        a.push_back(std::move(args));
        return *this;
    }
    template<class... Args>
    vec& emp(Args &&... args){
        a.emplace_back(std::forward<Args>(args) ...);
        return *this;
    }
    template<class Range>
    vec& app(Range& x){ for(auto& v : x){ emp(v); } return *this; }
    Elem pop(){ Elem x = std::move(a.back()); a.pop_back(); return x; }
    void resize(int sz){ a.resize(sz); }
    void reserve(int sz){ a.reserve(sz); }
    bool operator==(const vec& r) const { return a == r.a; }
    bool operator!=(const vec& r) const { return a != r.a; }
    bool operator<(const vec& r) const { return a < r.a; }
    bool operator<=(const vec& r) const { return a <= r.a; }
    bool operator>(const vec& r) const { return a > r.a; }
    bool operator>=(const vec& r) const { return a >= r.a; }
    vec<vec<Elem>> pile(int n) const { return vec<vec<Elem>>(n, *this); }
    template<class F> vec& filter(F f){
        int p = 0;
        for(auto& x : a) if(f(x)) std::swap(a[p++],x);
        resize(p); return *this;
    }
    vec& operator+=(const vec& r){ return app(r); }
    vec operator+(const vec& r) const { vec x = *this; x += r; return x; }
    vec operator*(int t) const { vec res; while(t--){ res += *this; } return res; }
private: Base a;
};

template<class IStr, class U, class T>
IStr& operator>>(IStr& is, vec<std::pair<U,T>>& v){ for(auto& x:v){ is >> x.first >> x.second; } return is; }
template<class IStr, class T>
IStr& operator>>(IStr& is, vec<T>& v){ for(auto& x:v){ is >> x; } return is; }
template<class OStr, class T>
OStr& operator<<(OStr& os, const vec<T>& v){
    for(int i=0; i<v.size(); i++){
        if(i){ os << ' '; } os << v[i];
    } return os;
}
template<class OStr, class U, class T>
OStr& operator<<(OStr& os, const vec<std::pair<U,T>>& v){
    for(int i=0; i<v.size(); i++){
        if(i){ os << ' '; } os << '(' << v[i].first << ',' << v[i].second << ')';
    } return os;
}

namespace nachia{

template<class Int = long long, class Int2 = long long>
struct VecI2 {
    Int x, y;
    VecI2() : x(0), y(0) {}
    VecI2(std::pair<Int, Int> _p) : x(std::move(_p.first)), y(std::move(_p.second)) {}
    VecI2(Int _x, Int _y) : x(std::move(_x)), y(std::move(_y)) {}
    VecI2& operator+=(VecI2 r){ x+=r.x; y+=r.y; return *this; }
    VecI2& operator-=(VecI2 r){ x-=r.x; y-=r.y; return *this; }
    VecI2& operator*=(Int r){ x*=r; y*=r; return *this; }
    VecI2 operator+(VecI2 r) const { return VecI2(x+r.x, y+r.y); }
    VecI2 operator-(VecI2 r) const { return VecI2(x-r.x, y-r.y); }
    VecI2 operator*(Int r) const { return VecI2(x*r, y*r); }
    VecI2 operator-() const { return VecI2(-x, -y); }
    Int2 operator*(VecI2 r) const { return Int2(x) * Int2(r.x) + Int2(y) * Int2(r.y); }
    Int2 operator^(VecI2 r) const { return Int2(x) * Int2(r.y) - Int2(y) * Int2(r.x); }
    bool operator<(VecI2 r) const { return x < r.x || (!(r.x < x) && y < r.y); }
    Int2 norm() const { return Int2(x) * Int2(x) + Int2(y) * Int2(y); }
    Int2 manhattan() const { return std::abs(x) + std::abs(y); }
    static bool compareYX(VecI2 a, VecI2 b){ return a.y < b.y || (!(b.y < a.y) && a.x < b.x); }
    static bool compareXY(VecI2 a, VecI2 b){ return a.x < b.x || (!(b.x < a.x) && a.y < b.y); }
    bool operator==(VecI2 r) const { return x == r.x && y == r.y; }
    bool operator!=(VecI2 r) const { return x != r.x || y != r.y; }
};

} // namespace nachia

#include <bitset>
#include <array>
#include <map>

void testcase(){
    using Vec2 = nachia::VecI2<int,int>;
    constexpr int NUM_KIND_PIECE = 6;

    auto dist = vec<int>(90,-1).pile(90).pile(NUM_KIND_PIECE);
    auto Index = [](Vec2 p){ return p.y * 9 + p.x; };
    vec<Vec2> pos(90);
    rep(y,10) rep(x,9) pos[Index({x,y})] = {x,y};
    string symbol = "JSCMXB";

    // construct dist
    {
        vec<vec<Vec2>> a(10);
        for(int i=-2; i<=2; i++) for(int j=-2; j<=2; j++) a[i*i+j*j].push({i,j});
        auto InRange = [](Vec2 p){ return 0 <= p.x && p.x <= 8 && 0 <= p.y && p.y <= 9; };
        //rep(d,10){
        //    for(auto [u,v] : a[d]) cout << "(" << u << "," << v << ")";
        //    cout << endl;
        //}
        vec<pair<int,int>> maps = {{0,1},{1,2},{3,5},{4,8}};
        for(auto [ty,eu] : maps){ // King J , Mandarin S, Knight M, Boshop X
            rep(s,90){
                vec<int> bfs = {s};
                dist[ty][s][s] = 0;
                rep(i,bfs.size()){
                    int v = bfs[i];
                    for(auto d : a[eu]) if(InRange(pos[v] + d)){
                        int t = Index(pos[v] + d);
                        if(dist[ty][s][t] >= 0) continue;
                        dist[ty][s][t] = dist[ty][s][v] + 1;
                        bfs.push(t);
                    }
                }
            }
        }
        rep(s,90) rep(t,90){ // Rook C
            dist[2][s][t] = (pos[s].x == pos[t].x ? 0 : 1) + (pos[s].y == pos[t].y ? 0 : 1);
        }
        rep(s,90) rep(t,90){ // Pawn B
            if(pos[s].y <= pos[t].y && (pos[t].y > 4 || pos[s].x == pos[t].x)){
                dist[5][s][t] = (pos[s] - pos[t]).manhattan();
            }
        }
        //rep(ty,NUM_KIND_PIECE){
        //    rep(y,10){
        //        rep(x,9) cout << dist[ty][0][Index({x,y})] << " ";
        //        cout << endl;
        //    } cout << endl << endl;
        //}
    }
    //rep(i,NUM_KIND_PIECE) cout << dist[i][Index({0,9})][Index({1,8})] << " ";
    //cout << endl;
    
    using Board = bitset<90>;
    using Cand = array<Board, NUM_KIND_PIECE>;

    vec<map<int,Cand>> questions(90);
    rep(t,90){
        map<int,Cand> buf;
        rep(ty,NUM_KIND_PIECE) rep(s,90){
            buf[dist[ty][s][t]][ty].set(s);
        }
        questions[t] = buf;
    }
    
    auto dfs = [&](auto& dfs, int k, Cand a) -> int {
        {
            int cnt = 0;
            rep(ty,NUM_KIND_PIECE) if(a[ty].any()) cnt += 1;
            if(cnt <= 1) return 0;
        }
        if(k == 0) return -1;
        rep(f,90){
            bool ok = true;
            for(auto [t,c] : questions[f]) if(ok){
                Cand b = a;
                rep(i,NUM_KIND_PIECE) b[i] &= c[i];
                if(dfs(dfs, k-1, b) == -1) ok = false;
            }
            if(ok) return f;
        }
        return -1;
    };

    Cand cand;
    //rep(t,6) rep(a,90) cand[t].set(a);
    //cout << dfs(dfs, 4, cand) << endl;
    //return;

    int N; cin >> N;
    rep(i,N){
        int r,c; cin >> r >> c;
        rep(t,6) cand[t].set(Index({c,r}));
    }
    bool first_q = true;
    while(true){
        int k = 0;
        int nx = -1;
        while(true){
            nx = dfs(dfs, k, cand);
            if(nx != -1) break;
            k++;
        }
        if(first_q){ cout << k << endl; first_q = false; }
        if(k == 0) break;
        cout << "? " << pos[nx].y << " " << pos[nx].x << endl;
        int res; cin >> res;
        rep(ty,NUM_KIND_PIECE) cand[ty] &= questions[nx][res][ty];
    }

    rep(ty,NUM_KIND_PIECE) if(cand[ty].any()){
        cout << "! " << symbol[ty] << endl;
    }
}

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    testcase();
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 4240kb

input:

1
9 0
8

output:

1
? 1 8
! S

result:

ok number is guessed.

Test #2:

score: 0
Accepted
time: 2ms
memory: 4208kb

input:

4
2 1
2 3
2 5
2 7
5
1

output:

2
? 0 0
? 0 6
! M

result:

ok number is guessed.

Test #3:

score: 0
Accepted
time: 2ms
memory: 4016kb

input:

1
2 4
-1
1

output:

2
? 0 0
? 0 2
! X

result:

ok number is guessed.

Test #4:

score: 0
Accepted
time: 2ms
memory: 3968kb

input:

1
5 0
6

output:

1
? 3 6
! S

result:

ok number is guessed.

Test #5:

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

input:

1
6 0
6

output:

1
? 0 2
! S

result:

ok number is guessed.

Test #6:

score: 0
Accepted
time: 2ms
memory: 4240kb

input:

2
7 7
1 0
-1
6

output:

2
? 0 0
? 7 2
! S

result:

ok number is guessed.

Test #7:

score: 0
Accepted
time: 2ms
memory: 3912kb

input:

5
8 6
1 3
0 5
2 4
0 2
6
3

output:

2
? 0 0
? 0 3
! J

result:

ok number is guessed.

Test #8:

score: 0
Accepted
time: 2ms
memory: 4252kb

input:

6
0 7
1 6
2 8
0 5
7 6
8 2
-1
14

output:

2
? 0 0
? 8 1
! B

result:

ok number is guessed.

Test #9:

score: 0
Accepted
time: 2ms
memory: 3972kb

input:

7
6 5
3 0
3 2
4 1
4 0
2 4
5 2
5
7

output:

2
? 0 0
? 0 4
! J

result:

ok number is guessed.

Test #10:

score: 0
Accepted
time: 2ms
memory: 4024kb

input:

8
3 3
2 5
6 2
7 4
1 4
3 0
2 4
3 4
7
-1

output:

2
? 0 1
? 0 0
! S

result:

ok number is guessed.

Test #11:

score: 0
Accepted
time: 3ms
memory: 4176kb

input:

9
2 7
2 4
2 5
2 2
2 1
2 0
2 6
2 3
2 8
6
8

output:

2
? 2 0
? 0 0
! J

result:

ok number is guessed.

Test #12:

score: 0
Accepted
time: 2ms
memory: 4176kb

input:

10
4 0
0 0
5 0
7 0
8 0
1 0
6 0
9 0
2 0
3 0
9
-1

output:

2
? 9 0
? 0 1
! B

result:

ok number is guessed.

Test #13:

score: 0
Accepted
time: 2ms
memory: 4208kb

input:

9
1 8
1 2
1 5
1 6
1 3
1 4
1 0
1 1
1 7
6
7

output:

2
? 1 0
? 0 0
! J

result:

ok number is guessed.

Test #14:

score: 0
Accepted
time: 3ms
memory: 3980kb

input:

10
0 4
5 4
8 4
2 4
4 4
7 4
3 4
9 4
6 4
1 4
11
5

output:

2
? 9 1
? 0 0
! J

result:

ok number is guessed.

Test #15:

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

input:

9
4 6
4 5
4 7
4 4
4 1
4 3
4 0
4 8
4 2
6
12

output:

2
? 4 2
? 0 0
! J

result:

ok number is guessed.

Test #16:

score: 0
Accepted
time: 3ms
memory: 4048kb

input:

10
9 2
5 2
1 2
8 2
6 2
7 2
2 2
0 2
4 2
3 2
10
3

output:

2
? 9 0
? 0 0
! J

result:

ok number is guessed.

Test #17:

score: 0
Accepted
time: 3ms
memory: 3892kb

input:

9
3 1
3 7
3 5
3 3
3 6
3 4
3 0
3 2
3 8
6
11

output:

2
? 3 2
? 0 0
! J

result:

ok number is guessed.

Test #18:

score: 0
Accepted
time: 2ms
memory: 4240kb

input:

10
5 1
8 1
6 1
4 1
3 1
0 1
2 1
7 1
9 1
1 1
10
-1

output:

2
? 9 0
? 0 0
! B

result:

ok number is guessed.

Test #19:

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

input:

9
1 6
1 4
1 3
1 7
1 8
1 5
1 2
1 1
1 0
6
7

output:

2
? 1 0
? 0 0
! J

result:

ok number is guessed.

Test #20:

score: 0
Accepted
time: 3ms
memory: 4028kb

input:

10
5 0
9 0
1 0
2 0
3 0
6 0
7 0
4 0
0 0
8 0
9
-1

output:

2
? 9 0
? 0 1
! B

result:

ok number is guessed.

Test #21:

score: 0
Accepted
time: 2ms
memory: 3972kb

input:

9
0 3
0 5
0 7
0 0
0 4
0 8
0 1
0 6
0 2
6
5

output:

2
? 0 0
? 0 1
! J

result:

ok number is guessed.

Test #22:

score: 0
Accepted
time: 3ms
memory: 4252kb

input:

10
1 0
9 0
4 0
2 0
8 0
7 0
5 0
3 0
0 0
6 0
9
-1

output:

2
? 9 0
? 0 1
! B

result:

ok number is guessed.

Test #23:

score: 0
Accepted
time: 2ms
memory: 3976kb

input:

9
1 8
1 2
1 7
1 0
1 4
1 6
1 1
1 5
1 3
6
7

output:

2
? 1 0
? 0 0
! J

result:

ok number is guessed.

Test #24:

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

input:

10
2 4
1 4
0 4
6 4
4 4
9 4
5 4
3 4
7 4
8 4
11
5

output:

2
? 9 1
? 0 0
! J

result:

ok number is guessed.

Test #25:

score: 0
Accepted
time: 2ms
memory: 3952kb

input:

9
0 2
0 7
0 5
0 4
0 0
0 3
0 1
0 6
0 8
6
5

output:

2
? 0 0
? 0 1
! J

result:

ok number is guessed.

Test #26:

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

input:

10
5 3
2 3
3 3
8 3
9 3
1 3
6 3
7 3
0 3
4 3
11
4

output:

2
? 9 0
? 0 0
! J

result:

ok number is guessed.

Test #27:

score: 0
Accepted
time: 3ms
memory: 4040kb

input:

50
7 5
9 2
0 4
9 3
8 4
8 2
7 2
6 4
4 4
0 0
1 7
1 1
1 5
2 0
9 8
9 0
3 1
7 8
8 6
5 0
7 3
8 5
2 6
4 8
3 5
6 8
0 8
5 7
4 6
1 6
3 8
5 6
3 0
5 3
0 7
5 1
3 4
0 1
7 6
2 3
4 3
5 5
8 1
0 3
6 5
9 5
5 8
7 4
6 3
2 7
-1
3
2

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #28:

score: 0
Accepted
time: 3ms
memory: 4180kb

input:

49
4 2
8 0
2 4
9 5
8 1
7 8
0 2
4 7
3 0
1 3
6 6
0 8
8 3
5 8
2 2
1 0
6 0
2 6
0 5
9 2
7 0
4 4
8 8
9 6
5 0
6 8
9 4
7 6
9 0
2 7
4 6
7 7
0 1
4 0
6 7
2 8
8 2
3 2
3 1
3 4
5 4
7 3
5 6
5 2
1 8
3 3
1 7
0 3
4 3
-1
3
4

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #29:

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

input:

48
6 7
3 5
0 3
5 7
1 6
9 6
6 2
0 7
5 5
0 4
0 5
0 8
6 4
4 2
8 5
1 2
1 3
8 1
2 7
0 2
2 6
7 1
6 5
0 1
3 7
6 8
7 4
3 3
5 4
5 1
4 4
8 8
7 5
0 0
1 0
7 6
7 7
3 0
7 8
4 0
9 2
9 7
6 6
2 1
6 1
5 2
5 6
4 1
-1
2
1

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #30:

score: 0
Accepted
time: 3ms
memory: 3952kb

input:

51
0 8
1 6
5 3
2 6
9 0
4 0
8 1
0 7
1 0
2 4
8 4
3 6
7 1
8 6
9 7
0 6
5 4
3 2
6 6
7 7
6 1
5 0
4 5
4 8
6 8
3 5
5 8
5 5
8 7
9 6
6 0
3 3
2 3
3 1
2 8
4 4
6 4
1 7
7 2
8 0
3 0
8 8
3 7
1 3
5 6
7 4
6 5
2 7
1 1
7 6
3 8
-1
4
-1

output:

3
? 0 0
? 1 0
? 0 1
! X

result:

ok number is guessed.

Test #31:

score: 0
Accepted
time: 3ms
memory: 3952kb

input:

52
1 6
3 8
0 6
9 2
6 4
5 4
2 1
1 0
4 2
2 2
3 2
9 6
7 1
0 2
8 7
1 4
3 1
8 0
3 0
5 8
1 5
7 4
5 7
5 1
6 8
1 2
9 0
6 5
0 4
4 0
5 5
5 0
2 6
6 2
8 5
7 0
0 7
5 3
9 3
0 1
3 5
8 1
4 5
4 6
7 5
8 3
7 8
7 2
3 3
2 5
8 8
2 8
-1
4
5

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #32:

score: 0
Accepted
time: 3ms
memory: 4036kb

input:

89
3 1
7 3
3 0
3 5
0 0
1 3
1 1
3 3
8 8
7 7
2 4
7 0
9 3
2 0
3 7
6 6
7 2
7 1
4 4
2 8
1 2
9 4
9 2
3 8
9 5
6 5
3 4
8 0
2 1
0 4
4 2
1 5
4 7
4 3
7 8
5 6
0 8
0 2
8 7
9 0
5 8
9 8
5 4
0 6
0 5
5 5
7 6
5 0
6 0
6 1
1 0
5 2
8 6
7 5
4 5
9 1
1 4
8 4
4 8
4 6
9 7
1 6
5 3
8 5
9 6
3 6
0 1
6 8
1 8
1 7
4 0
0 3
6 7
0 7
2...

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #33:

score: 0
Accepted
time: 3ms
memory: 4252kb

input:

89
7 4
2 6
9 2
0 1
0 4
8 0
6 5
4 1
7 5
0 2
5 3
1 0
9 5
2 7
7 7
7 1
2 1
8 8
0 0
1 1
9 3
3 0
4 7
5 5
6 8
8 3
0 3
7 2
8 5
0 8
4 6
0 6
6 0
8 6
8 4
2 8
3 8
9 7
1 7
5 6
8 2
7 6
5 1
1 5
2 2
6 3
2 4
9 6
4 3
4 4
4 5
5 7
3 3
4 0
9 1
6 7
9 4
1 3
3 1
6 4
1 4
0 7
9 0
1 2
0 5
6 1
7 3
8 1
9 8
2 3
3 5
2 5
5 0
8 7
7...

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #34:

score: 0
Accepted
time: 4ms
memory: 4208kb

input:

89
2 2
5 3
0 1
6 1
3 7
8 5
0 3
0 8
7 1
9 4
9 7
6 3
2 1
5 6
1 6
9 0
5 5
6 7
2 4
7 4
9 5
6 5
8 3
0 0
2 3
7 3
6 8
8 8
3 3
2 5
6 4
5 2
5 0
5 1
3 1
1 4
5 8
9 8
1 8
2 6
4 0
2 0
3 4
1 3
2 8
3 2
4 4
3 0
6 0
0 5
9 1
4 7
4 2
3 6
4 8
6 2
1 5
1 7
7 8
4 6
7 0
0 4
6 6
2 7
9 3
8 0
5 7
8 6
7 7
9 2
9 6
8 7
8 4
3 5
4...

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #35:

score: 0
Accepted
time: 3ms
memory: 3948kb

input:

89
3 3
4 4
8 2
7 8
4 7
7 6
1 5
5 4
9 5
3 8
6 2
0 1
3 0
1 6
0 7
3 4
4 8
8 1
4 6
5 5
4 0
4 5
2 3
7 3
7 2
1 1
9 8
4 3
3 7
5 8
1 8
1 0
4 1
5 2
2 4
0 6
8 8
6 1
9 0
2 6
3 6
1 7
6 3
8 0
1 3
2 0
6 0
8 6
8 5
7 5
9 2
9 1
3 1
9 6
3 2
5 7
0 3
6 6
0 4
6 4
5 3
5 0
2 8
7 4
0 2
2 2
2 1
6 8
2 5
7 1
8 3
0 8
0 0
9 3
7...

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #36:

score: 0
Accepted
time: 3ms
memory: 4016kb

input:

89
5 0
7 0
0 2
0 7
1 5
3 6
2 6
7 8
6 5
5 5
8 2
6 0
1 4
4 7
4 4
6 3
9 4
8 3
0 4
2 3
4 6
3 3
6 7
6 6
3 0
1 6
6 8
8 6
7 5
1 2
2 8
6 4
6 1
1 8
0 1
2 1
3 4
0 6
0 0
4 3
1 3
3 1
8 4
5 4
3 5
7 3
6 2
9 3
2 2
8 7
5 8
9 0
9 1
9 5
4 1
2 7
9 7
4 8
7 2
7 7
5 3
4 5
5 1
5 7
7 6
3 8
7 4
2 5
9 2
4 2
1 1
1 7
4 0
9 8
7...

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #37:

score: 0
Accepted
time: 3ms
memory: 4040kb

input:

90
9 6
6 2
8 8
6 4
9 2
4 1
3 6
2 7
8 6
6 0
9 8
3 2
7 5
5 7
1 6
5 3
5 0
8 4
2 4
2 0
0 4
4 5
1 3
4 4
4 3
7 8
6 8
3 5
0 5
5 2
8 0
7 0
5 6
9 7
3 0
1 2
1 4
3 8
6 3
3 3
4 2
9 5
7 4
7 3
3 1
0 6
2 2
5 1
3 7
4 8
0 3
9 4
1 7
2 8
1 0
9 3
0 7
0 2
4 7
0 0
7 6
3 4
6 1
7 7
2 6
8 3
8 1
4 0
5 5
1 8
5 4
4 6
1 5
9 0
2...

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #38:

score: 0
Accepted
time: 3ms
memory: 4020kb

input:

90
9 6
7 3
8 7
1 2
9 4
6 5
9 7
0 5
0 3
5 8
0 0
1 6
1 3
8 8
9 3
4 3
7 8
3 7
3 5
8 5
5 7
1 0
5 4
5 2
0 1
9 0
6 8
6 4
3 4
1 1
4 4
9 2
6 2
0 4
8 0
2 2
1 4
0 6
4 7
3 0
7 5
2 7
8 6
5 0
4 6
2 3
7 7
9 1
2 5
9 5
7 0
5 3
4 5
3 3
4 0
8 4
7 2
3 1
0 8
5 5
2 8
7 4
8 3
0 2
0 7
1 5
7 1
2 1
3 6
9 8
5 1
7 6
2 6
1 7
4...

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #39:

score: 0
Accepted
time: 3ms
memory: 4024kb

input:

90
5 7
7 2
6 6
2 4
1 5
0 3
9 8
5 0
4 1
3 1
5 6
8 5
4 0
4 6
3 3
1 2
7 0
4 2
0 4
4 5
0 1
8 8
8 6
9 3
7 5
5 2
6 8
8 2
6 2
4 7
3 5
2 0
0 5
8 4
8 3
2 2
6 3
9 5
4 8
1 4
4 4
6 7
2 8
1 7
0 0
6 5
9 1
1 3
9 4
9 0
7 3
7 7
9 2
1 0
6 4
2 7
2 5
6 1
3 4
0 7
5 8
2 6
0 8
3 8
7 1
4 3
3 0
3 2
8 1
8 7
9 6
2 1
9 7
1 1
0...

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #40:

score: 0
Accepted
time: 3ms
memory: 4024kb

input:

90
7 6
4 2
9 4
7 1
0 7
7 3
0 2
6 2
6 3
3 4
2 7
4 4
8 5
4 3
3 2
6 7
1 8
1 0
3 8
0 4
4 5
8 0
5 8
0 6
1 6
8 4
6 8
8 6
6 6
4 0
8 1
6 1
2 4
7 5
8 2
9 6
0 0
7 8
4 7
5 1
7 4
2 1
8 3
6 5
2 5
5 4
1 1
3 0
3 5
5 7
9 1
1 5
9 7
9 8
0 3
7 0
0 1
2 8
5 3
6 0
9 0
4 6
4 1
4 8
2 2
5 2
3 7
1 2
3 3
1 3
9 2
7 7
5 6
2 3
0...

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #41:

score: 0
Accepted
time: 3ms
memory: 4040kb

input:

90
2 0
5 6
9 0
7 3
4 7
9 3
2 8
3 5
7 6
6 1
0 7
0 8
4 6
2 2
8 3
2 6
7 4
9 6
2 1
6 2
4 1
7 0
0 0
1 7
6 5
1 1
6 8
2 3
6 0
9 7
1 2
2 7
3 3
5 4
3 6
1 6
0 3
0 5
4 3
6 3
2 4
1 3
7 7
8 1
6 7
3 1
9 4
8 7
9 1
3 2
4 8
9 2
1 4
4 0
8 5
6 4
8 0
0 2
3 0
1 0
6 6
8 6
9 5
5 2
4 2
2 5
7 1
5 8
5 3
8 8
3 8
5 0
7 5
5 1
1...

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #42:

score: 0
Accepted
time: 4ms
memory: 4208kb

input:

90
6 6
3 6
3 1
3 8
9 5
7 0
7 6
2 6
8 4
4 6
8 0
6 2
7 3
9 2
8 3
7 1
1 8
1 1
3 4
2 4
6 4
0 1
0 8
5 2
0 6
1 7
4 0
2 7
2 0
3 7
8 6
1 0
7 2
5 0
0 0
1 3
1 6
3 3
5 1
8 5
0 5
4 3
5 5
4 1
2 1
1 4
3 2
2 3
4 7
0 2
2 8
5 3
9 1
5 4
6 3
6 8
5 7
9 8
4 5
0 3
5 6
7 7
9 7
7 5
3 5
6 7
5 8
1 2
4 2
7 8
8 1
8 8
6 5
9 0
4...

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #43:

score: 0
Accepted
time: 3ms
memory: 4020kb

input:

90
5 4
6 7
7 6
8 5
1 0
5 8
0 7
4 2
9 3
8 1
3 0
7 3
0 4
1 4
7 8
8 8
9 0
1 3
3 7
6 3
3 2
2 7
2 3
5 7
6 2
5 2
3 5
2 1
1 1
0 8
8 2
0 2
6 6
9 4
7 0
3 3
2 8
2 4
3 1
9 7
1 5
5 3
2 5
5 0
9 6
8 0
9 8
7 5
6 1
1 2
9 1
6 5
1 8
4 3
3 8
6 8
0 3
4 5
1 7
6 0
4 1
0 1
5 1
8 4
8 6
7 7
3 4
4 4
6 4
4 8
3 6
4 6
4 0
2 6
2...

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #44:

score: 0
Accepted
time: 3ms
memory: 3956kb

input:

90
4 7
2 0
6 2
9 8
2 1
1 2
0 6
3 6
1 1
9 6
7 4
9 2
7 2
0 8
2 8
2 4
4 6
6 0
7 8
9 7
4 5
1 7
6 4
0 4
3 3
3 5
5 8
9 0
5 3
4 2
4 0
5 1
8 5
3 0
0 0
5 2
9 5
8 2
8 8
0 1
5 7
3 1
1 5
6 1
5 6
8 1
0 2
3 8
4 4
6 5
0 7
2 6
7 7
3 2
6 8
9 1
5 0
6 6
0 3
3 4
6 3
7 6
4 3
5 5
0 5
4 1
1 8
9 3
2 3
5 4
8 6
2 7
3 7
4 8
9...

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #45:

score: 0
Accepted
time: 3ms
memory: 4244kb

input:

90
2 1
6 0
4 3
6 7
3 5
1 4
4 1
2 3
3 6
2 5
7 5
3 2
2 7
5 5
5 3
1 7
0 3
7 1
8 2
5 8
2 4
6 1
8 7
7 2
9 5
0 5
3 1
0 6
3 3
6 6
9 8
9 4
8 0
8 4
5 1
7 8
2 0
5 2
4 4
7 0
1 5
2 2
8 3
1 6
3 7
1 0
1 2
0 1
5 6
3 4
8 6
9 0
6 4
9 1
1 1
7 4
7 7
8 1
5 7
0 4
3 8
1 3
8 8
4 0
4 8
6 3
4 2
6 2
4 7
7 6
0 2
2 8
2 6
0 7
5...

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Test #46:

score: 0
Accepted
time: 3ms
memory: 4040kb

input:

90
0 3
1 3
4 0
9 0
4 6
8 6
6 6
0 8
0 2
7 2
7 1
3 8
1 7
7 6
5 4
9 6
2 1
2 3
6 4
3 7
8 7
0 6
8 2
3 1
4 2
5 1
7 8
6 7
2 8
2 4
6 0
5 5
3 6
9 5
9 3
2 2
8 0
1 2
2 5
8 3
0 5
0 4
4 4
3 4
0 0
6 5
4 7
8 1
1 0
9 1
0 1
5 0
8 5
0 7
6 1
6 8
7 3
8 8
9 7
9 2
1 6
2 7
1 1
6 2
4 8
1 8
5 6
7 5
2 6
7 4
9 4
5 7
1 4
6 3
3...

output:

3
? 0 0
? 1 0
? 0 1
! S

result:

ok number is guessed.

Extra Test:

score: 0
Extra Test Passed