QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#354867#2495. Knight's MoveEnergy_is_not_overAC ✓500ms13592kbC++145.9kb2024-03-16 06:21:212024-03-16 06:21:22

Judging History

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

  • [2024-03-16 06:21:22]
  • 评测
  • 测评结果:AC
  • 用时:500ms
  • 内存:13592kb
  • [2024-03-16 06:21:21]
  • 提交

answer

//
// Created by BigBag on 15.03.2024 20:18:32
//

#include <bits/stdc++.h>

using namespace std;

#ifdef BigBag
#define DEBUG for (bool ____DEBUG = true; ____DEBUG; ____DEBUG = false)
#define LOG(...) print(#__VA_ARGS__" ::", __VA_ARGS__) << endl

template<class ...Ts>
auto &print(Ts ...ts) { return ((cerr << ts << " "), ...); }

#else
#define DEBUG while (false)
#define LOG(...)
#endif

const int max_n = -1, inf = 1000111222;

template<class ForwardIt, class UnaryPredicate>
ForwardIt remove_if(ForwardIt first, ForwardIt last, UnaryPredicate p)
{
    first = std::find_if(first, last, p);
    if (first != last)
        for (ForwardIt i = first; ++i != last;)
            if (!p(*i))
                *first++ = std::move(*i);
    return first;
}

template< class T, class Alloc, class Pred >
constexpr typename std::vector<T, Alloc>::size_type
erase_if( std::vector<T, Alloc>& c, Pred pred ) {
    auto it = std::remove_if(c.begin(), c.end(), pred);
    auto r = c.end() - it;
    c.erase(it, c.end());
    return r;
}

struct VertexInfo {
    int pr, nxt, jump;
    VertexInfo(int v): pr(v), nxt(v), jump(v) {}
};
struct PathHolder {
    const int jump_sz;
    vector<VertexInfo> a;
    PathHolder(int n): jump_sz(sqrt(n) + 0.47) {
        a.assign(n, 0);
        iota(a.begin(), a.end(), 0);
    }
    void delEdge(int u, int v) {
        a[v].pr = v;
        a[u].nxt = u;
        for (int i = 0, x = u; i < jump_sz; ++i) {
            a[x].jump = u, x = a[x].pr;
        }
    }
    void addEdge(int u, int v) {
        a[u].nxt = v;
        a[v].pr = u;
        int x = u, steps = 0;
        while (steps + 1 < jump_sz && x != a[x].pr) {
            x = a[x].pr;
            ++steps;
        }
        int f = u;
        while ((++steps) <= jump_sz) f = a[f].nxt;
        for (; x != u; x = a[x].nxt, f = a[f].nxt) {
            a[x].jump = f;
        }
        a[x].jump = f;
    }
    int getRoot(int v) const {
        while (v != a[v].jump) v = a[v].jump;
        return v;
    }
    VertexInfo& operator [](int v) { return a[v]; }
    bool in(int v) const { return v != a[v].pr; }
    bool out(int v) const { return v != a[v].nxt; }
};
vector<int> HF(int n, vector<pair<int, int>> e) {
    int ops = 4e6, fails = 0, tot = 0;
    PathHolder p(n);
    mt19937 gen(time(0) + clock());
    vector<vector<int>> g(n), rg(n);
    for (auto p : e) {
        g[p.first].push_back(p.second);
        rg[p.second].push_back(p.first);
    }
    vector<int> s(n), t(n);
    iota(s.begin(), s.end(), 0);
    iota(t.begin(), t.end(), 0);
    while (fails < (n + 47) * 10 && (n == 1 || !e.empty())) {
        e.clear();
        erase_if(s, [&](int v) {return p.in(v);});
        erase_if(t, [&](int v) {return p.out(v);});
        for (int to : s) for (int from : rg[to])
                if (p.out(from)) e.push_back({from, to});
        for (int from : t) for (int to : g[from])
                e.push_back({from, to});
        shuffle(e.begin(), e.end(), gen);
        for (auto [u, v] : e) {
            --ops, ++fails;
            if ((p.out(u) && p.in(v))) continue;
            if (p.getRoot(u) == p.getRoot(v)) continue;
            if ((p.out(u) || p.in(v)) && gen() % 2)
                continue;
            if (p.out(u)) {
                s.push_back(p[u].nxt);
                p.delEdge(u, p[u].nxt);
            } else if (p.in(v)) {
                t.push_back(p[v].pr);
                p.delEdge(p[v].pr, v);
            } else ++tot, fails = 0;
            p.addEdge(u, v);
        }
        if (tot + 1 == n) {
            int v = p.getRoot(0);
            vector<int> res;
            for (int i = 0; i < n; ++i, v = p[v].pr)
                res.push_back(v);
            return {res.rbegin(), res.rend()};
        }
    }
    return {};
}

vector<int> find_cycle(int n, vector<pair<int, int>> e) {
    vector<pair<int, int>> ne;
    int s = n, t = n + 1;
    for (auto [u, v] : e) {
        if (v == 7) {
            ne.push_back({u, t});
        } else {
            ne.push_back({u, v});
        }
    }
    ne.push_back({s, 7});
    auto res = HF(n + 2, ne);
    if (!res.empty()) {
        assert(res[0] == s && res.back() == t);
        res.pop_back();
        res.erase(res.begin());
    }
    return res;
}

const int dx[] = {-1, -1, -2, -2, 1, 1, 2, 2};
const int dy[] = {-2, 2, -1, 1, -2, 2, -1, 1};

int n;

int get_num(int tp, int x, int y) {
    return tp * (n * n - 2) + x * n + y - 1;
}

bool is_in(int x, int y) {
    return 0 <= x && 0 <= y && x < n && y < n && 0 < x + y && x + y < 2 * n - 2;
}

vector<array<int, 3>> solve() {
    vector<pair<int, int>> e;
    for (int tp = 0; tp < 2; ++tp) {
        for (int x = 0; x < n; ++x) {
            for (int y = 0; y < n; ++y) {
                if (!is_in(x, y)) {
                    continue;
                }
                e.push_back({get_num(tp, x, y), get_num(tp ^ 1, x, y)});
                for (int k = 0; k < 8; ++k) {
                    const int nx = x + dx[k], ny = y + dy[k];
                    if (is_in(nx, ny)) {
                        e.push_back({get_num(tp, x, y), get_num(tp, nx, ny)});
                    }
                }
            }
        }
    }
    auto vs = find_cycle(2 * n * n - 4, e);
    while (vs.empty()) {
        vs = find_cycle(2 * n * n - 4, e);
    }
    vector<array<int, 3>> res;
    for (int v : vs) {
        int tp = v / (n * n - 2);
        v %= (n * n - 2);
        ++v;
        int x = v / n, y = v % n;
        res.push_back({1 + x, 1 + y, tp});
    }
    return res;
}

int main() {
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    auto ans = solve();
    for (auto a : ans) {
        cout << a[0] << " " << a[1] << " " << a[2] << endl;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4

output:

3 1 0
4 3 0
2 2 0
4 1 0
4 1 1
3 3 1
2 1 1
2 1 0
4 2 0
4 2 1
3 4 1
3 4 0
1 3 0
1 3 1
3 2 1
3 2 0
2 4 0
2 4 1
1 2 1
1 2 0
3 3 0
1 4 0
1 4 1
2 2 1
4 3 1
3 1 1
2 3 1
2 3 0

result:

ok good job

Test #2:

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

input:

6

output:

2 3 0
4 4 0
5 6 0
5 6 1
4 4 1
3 6 1
5 5 1
5 5 0
3 6 0
2 4 0
1 2 0
3 1 0
4 3 0
6 2 0
4 1 0
4 1 1
2 2 1
2 2 0
3 4 0
1 3 0
1 3 1
3 4 1
2 6 1
2 6 0
4 5 0
6 4 0
6 4 1
4 5 1
2 4 1
1 2 1
3 1 1
5 2 1
5 2 0
3 3 0
2 5 0
2 5 1
4 6 1
4 6 0
6 5 0
6 5 1
5 3 1
5 3 0
6 1 0
6 1 1
4 2 1
6 3 1
6 3 0
5 1 0
3 2 0
3 2 1
...

result:

ok good job

Test #3:

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

input:

8

output:

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

result:

ok good job

Test #4:

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

input:

10

output:

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

result:

ok good job

Test #5:

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

input:

12

output:

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

result:

ok good job

Test #6:

score: 0
Accepted
time: 11ms
memory: 3840kb

input:

14

output:

1 9 0
2 11 0
1 13 0
3 14 0
4 12 0
5 14 0
3 13 0
3 13 1
1 14 1
1 14 0
2 12 0
1 10 0
1 10 1
2 8 1
3 10 1
5 11 1
7 10 1
7 10 0
8 12 0
6 13 0
5 11 0
4 9 0
3 11 0
2 9 0
4 10 0
5 12 0
7 11 0
5 10 0
6 12 0
7 14 0
9 13 0
11 12 0
10 14 0
10 14 1
9 12 1
11 13 1
13 14 1
13 14 0
14 12 0
14 12 1
12 11 1
10 10 1
...

result:

ok good job

Test #7:

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

input:

16

output:

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

result:

ok good job

Test #8:

score: 0
Accepted
time: 5ms
memory: 4260kb

input:

18

output:

1 9 0
1 9 1
2 7 1
3 5 1
4 3 1
3 1 1
2 3 1
1 5 1
1 5 0
3 4 0
5 3 0
6 1 0
7 3 0
9 2 0
10 4 0
9 6 0
10 8 0
11 10 0
9 11 0
7 12 0
8 10 0
8 10 1
6 9 1
7 7 1
8 5 1
6 6 1
7 4 1
7 4 0
8 6 0
9 4 0
8 2 0
10 1 0
11 3 0
12 1 0
12 1 1
14 2 1
16 3 1
18 4 1
17 6 1
15 5 1
17 4 1
18 6 1
16 7 1
17 9 1
18 11 1
16 12 1...

result:

ok good job

Test #9:

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

input:

20

output:

1 9 0
2 7 0
3 5 0
1 4 0
2 6 0
4 5 0
3 3 0
4 1 0
5 3 0
6 1 0
4 2 0
2 1 0
2 1 1
1 3 1
1 3 0
3 2 0
3 2 1
2 4 1
1 2 1
3 1 1
3 1 0
1 2 0
2 4 0
4 3 0
6 4 0
7 6 0
6 8 0
6 8 1
5 10 1
5 10 0
6 12 0
6 12 1
8 11 1
10 12 1
11 14 1
13 15 1
14 17 1
16 16 1
15 14 1
17 13 1
19 14 1
17 15 1
15 16 1
13 17 1
12 19 1
1...

result:

ok good job

Test #10:

score: 0
Accepted
time: 8ms
memory: 4380kb

input:

22

output:

1 9 0
1 9 1
3 10 1
1 11 1
2 13 1
3 15 1
1 16 1
2 18 1
4 19 1
3 21 1
3 21 0
5 22 0
7 21 0
8 19 0
10 20 0
8 21 0
10 22 0
12 21 0
11 19 0
13 20 0
13 20 1
15 19 1
17 18 1
18 20 1
16 21 1
14 22 1
12 21 1
14 20 1
15 18 1
13 17 1
14 19 1
14 19 0
15 21 0
17 22 0
18 20 0
20 21 0
19 19 0
18 21 0
16 20 0
15 18...

result:

ok good job

Test #11:

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

input:

24

output:

1 9 0
1 9 1
2 11 1
1 13 1
1 13 0
3 12 0
2 10 0
4 11 0
6 12 0
4 13 0
3 15 0
1 14 0
2 12 0
3 14 0
2 16 0
4 17 0
6 16 0
7 18 0
6 20 0
8 21 0
6 22 0
7 20 0
5 21 0
5 21 1
4 23 1
2 24 1
2 24 0
4 23 0
2 22 0
1 20 0
3 21 0
1 22 0
1 22 1
3 21 1
4 19 1
6 20 1
8 21 1
10 22 1
9 24 1
8 22 1
6 23 1
8 24 1
10 23 1...

result:

ok good job

Test #12:

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

input:

26

output:

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

result:

ok good job

Test #13:

score: 0
Accepted
time: 6ms
memory: 4452kb

input:

28

output:

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

result:

ok good job

Test #14:

score: 0
Accepted
time: 7ms
memory: 4660kb

input:

30

output:

1 9 0
1 9 1
2 7 1
3 5 1
2 3 1
1 5 1
3 4 1
4 2 1
6 1 1
7 3 1
9 2 1
7 1 1
6 3 1
5 5 1
7 6 1
6 8 1
7 10 1
5 11 1
4 9 1
5 7 1
6 5 1
6 5 0
8 4 0
10 5 0
9 3 0
11 2 0
10 4 0
9 6 0
8 8 0
10 7 0
8 6 0
7 4 0
8 2 0
6 3 0
7 1 0
9 2 0
11 1 0
13 2 0
13 2 1
14 4 1
15 6 1
13 7 1
14 9 1
12 8 1
10 7 1
8 8 1
9 10 1
8 ...

result:

ok good job

Test #15:

score: 0
Accepted
time: 7ms
memory: 4300kb

input:

32

output:

1 9 0
2 11 0
3 9 0
4 7 0
5 9 0
4 11 0
6 10 0
5 8 0
4 10 0
4 10 1
3 8 1
5 9 1
4 11 1
3 13 1
4 15 1
2 16 1
1 18 1
1 18 0
3 19 0
3 19 1
4 21 1
2 20 1
3 18 1
1 17 1
2 15 1
1 13 1
3 14 1
5 15 1
6 13 1
5 11 1
3 10 1
1 9 1
2 7 1
1 5 1
2 3 1
3 1 1
1 2 1
2 4 1
4 3 1
6 4 1
4 5 1
5 7 1
6 5 1
8 6 1
8 6 0
10 7 0...

result:

ok good job

Test #16:

score: 0
Accepted
time: 12ms
memory: 4640kb

input:

34

output:

1 9 0
3 8 0
4 6 0
6 7 0
8 6 0
7 8 0
6 10 0
5 12 0
4 10 0
6 9 0
5 11 0
7 12 0
8 14 0
10 15 0
8 16 0
8 16 1
9 18 1
9 18 0
10 20 0
8 21 0
8 21 1
10 20 1
11 18 1
12 20 1
14 21 1
16 20 1
16 20 0
14 21 0
15 23 0
16 25 0
14 24 0
12 23 0
11 21 0
11 21 1
13 20 1
15 19 1
15 19 0
16 17 0
16 17 1
14 18 1
12 19 ...

result:

ok good job

Test #17:

score: 0
Accepted
time: 12ms
memory: 4540kb

input:

36

output:

1 9 0
2 7 0
1 5 0
1 5 1
2 3 1
4 2 1
6 1 1
5 3 1
7 2 1
6 4 1
7 6 1
8 4 1
10 5 1
12 6 1
12 6 0
14 7 0
15 9 0
13 8 0
14 6 0
12 7 0
11 9 0
13 10 0
14 12 0
12 13 0
13 15 0
14 17 0
14 17 1
16 18 1
18 17 1
16 16 1
17 18 1
15 17 1
15 17 0
17 18 0
16 20 0
17 22 0
19 21 0
19 21 1
20 23 1
20 23 0
22 22 0
23 20...

result:

ok good job

Test #18:

score: 0
Accepted
time: 7ms
memory: 4968kb

input:

38

output:

1 9 0
2 11 0
3 9 0
1 10 0
2 8 0
4 9 0
3 11 0
5 12 0
4 10 0
6 11 0
7 13 0
9 14 0
9 14 1
10 12 1
10 12 0
12 11 0
14 10 0
13 12 0
11 11 0
13 10 0
15 11 0
16 13 0
17 15 0
18 13 0
18 13 1
17 11 1
17 11 0
16 9 0
14 8 0
13 6 0
14 4 0
15 6 0
16 8 0
17 6 0
19 7 0
21 6 0
22 8 0
23 10 0
21 11 0
20 9 0
19 11 0
...

result:

ok good job

Test #19:

score: 0
Accepted
time: 17ms
memory: 5140kb

input:

40

output:

1 9 0
2 11 0
1 13 0
1 13 1
3 14 1
1 15 1
2 13 1
1 11 1
1 11 0
3 10 0
5 9 0
3 8 0
4 10 0
4 10 1
3 12 1
2 14 1
1 12 1
1 12 0
2 10 0
2 10 1
3 8 1
5 9 1
7 8 1
6 10 1
4 11 1
5 13 1
7 12 1
5 11 1
4 13 1
6 14 1
5 16 1
7 15 1
9 14 1
8 16 1
7 18 1
6 16 1
4 15 1
4 15 0
2 16 0
1 18 0
2 20 0
3 18 0
1 19 0
3 20 ...

result:

ok good job

Test #20:

score: 0
Accepted
time: 11ms
memory: 5140kb

input:

42

output:

1 9 0
3 10 0
4 8 0
3 6 0
5 7 0
6 5 0
4 6 0
2 5 0
2 5 1
1 3 1
1 3 0
3 2 0
5 1 0
4 3 0
2 4 0
1 2 0
1 2 1
3 1 1
3 1 0
2 3 0
1 5 0
1 5 1
2 3 1
3 5 1
3 5 0
5 4 0
3 3 0
2 1 0
4 2 0
4 2 1
2 1 1
3 3 1
5 2 1
5 2 0
4 4 0
5 6 0
7 7 0
6 9 0
6 9 1
7 7 1
8 9 1
9 11 1
10 13 1
12 12 1
14 11 1
16 12 1
15 10 1
14 12 ...

result:

ok good job

Test #21:

score: 0
Accepted
time: 11ms
memory: 5232kb

input:

44

output:

1 9 0
2 7 0
2 7 1
4 8 1
3 10 1
2 12 1
1 14 1
3 13 1
4 11 1
2 10 1
1 8 1
1 8 0
3 7 0
4 5 0
2 6 0
4 7 0
4 7 1
2 8 1
1 6 1
2 4 1
1 2 1
3 1 1
2 3 1
3 5 1
1 4 1
1 4 0
3 3 0
3 3 1
5 2 1
7 3 1
8 5 1
6 6 1
8 7 1
8 7 0
10 6 0
8 5 0
6 6 0
5 4 0
3 5 0
1 6 0
2 4 0
1 2 0
3 1 0
2 3 0
4 2 0
6 3 0
4 4 0
5 2 0
7 1 0...

result:

ok good job

Test #22:

score: 0
Accepted
time: 13ms
memory: 5604kb

input:

46

output:

1 9 0
3 10 0
5 9 0
6 11 0
6 11 1
4 12 1
3 14 1
5 15 1
6 13 1
4 14 1
5 12 1
3 11 1
2 13 1
1 15 1
2 17 1
2 17 0
4 18 0
5 20 0
5 20 1
4 22 1
3 20 1
3 20 0
1 21 0
1 21 1
2 19 1
1 17 1
3 16 1
4 18 1
6 19 1
8 20 1
8 20 0
7 22 0
6 20 0
4 19 0
5 21 0
5 21 1
6 23 1
7 25 1
8 27 1
6 28 1
7 26 1
5 27 1
6 29 1
4...

result:

ok good job

Test #23:

score: 0
Accepted
time: 60ms
memory: 5956kb

input:

48

output:

1 9 0
2 7 0
1 5 0
3 6 0
3 6 1
1 5 1
2 3 1
3 5 1
1 6 1
3 7 1
5 6 1
5 6 0
4 8 0
6 9 0
5 7 0
6 5 0
8 4 0
10 3 0
11 1 0
9 2 0
11 3 0
10 1 0
10 1 1
8 2 1
10 3 1
9 1 1
11 2 1
13 1 1
14 3 1
15 5 1
14 7 1
15 9 1
16 11 1
18 10 1
17 12 1
16 10 1
17 8 1
16 6 1
16 6 0
15 8 0
16 10 0
14 11 0
15 13 0
17 14 0
19 1...

result:

ok good job

Test #24:

score: 0
Accepted
time: 15ms
memory: 5892kb

input:

50

output:

1 9 0
2 7 0
3 5 0
5 4 0
6 2 0
8 3 0
10 2 0
8 1 0
8 1 1
9 3 1
9 3 0
7 4 0
8 2 0
10 3 0
11 1 0
11 1 1
10 3 1
12 2 1
14 3 1
16 2 1
17 4 1
19 3 1
17 2 1
18 4 1
20 5 1
22 6 1
21 8 1
20 10 1
18 9 1
19 7 1
17 8 1
16 6 1
18 5 1
16 4 1
15 6 1
13 7 1
11 6 1
10 4 1
8 5 1
10 6 1
8 7 1
7 9 1
5 8 1
4 10 1
3 12 1
...

result:

ok good job

Test #25:

score: 0
Accepted
time: 42ms
memory: 6160kb

input:

52

output:

1 9 0
1 9 1
3 10 1
5 9 1
7 8 1
6 10 1
7 12 1
9 13 1
11 12 1
13 13 1
15 12 1
14 10 1
15 8 1
15 8 0
14 10 0
15 12 0
17 11 0
19 10 0
20 12 0
20 12 1
22 13 1
20 14 1
19 12 1
18 14 1
17 16 1
15 17 1
16 15 1
16 15 0
15 13 0
17 12 0
19 13 0
18 15 0
16 16 0
17 14 0
19 15 0
20 17 0
18 18 0
17 20 0
19 21 0
17...

result:

ok good job

Test #26:

score: 0
Accepted
time: 48ms
memory: 6288kb

input:

54

output:

1 9 0
1 9 1
3 10 1
4 12 1
6 11 1
4 10 1
2 11 1
3 13 1
4 15 1
5 17 1
3 16 1
2 18 1
1 20 1
3 21 1
4 19 1
5 21 1
6 19 1
4 18 1
5 16 1
6 18 1
4 17 1
3 19 1
3 19 0
1 20 0
2 22 0
2 22 1
1 24 1
3 25 1
3 25 0
5 24 0
4 22 0
6 23 0
7 21 0
5 20 0
4 18 0
2 17 0
1 15 0
2 13 0
4 12 0
6 11 0
7 13 0
6 15 0
4 16 0
4...

result:

ok good job

Test #27:

score: 0
Accepted
time: 159ms
memory: 6776kb

input:

56

output:

1 9 0
2 7 0
4 8 0
5 6 0
7 5 0
9 4 0
8 2 0
10 3 0
11 1 0
12 3 0
13 1 0
15 2 0
17 3 0
18 1 0
16 2 0
15 4 0
17 5 0
16 3 0
15 1 0
14 3 0
13 5 0
14 7 0
14 7 1
13 5 1
14 3 1
16 4 1
15 2 1
13 1 1
11 2 1
13 3 1
15 4 1
16 2 1
18 1 1
20 2 1
20 2 0
22 3 0
20 4 0
19 6 0
20 8 0
18 7 0
17 9 0
19 10 0
21 11 0
20 9...

result:

ok good job

Test #28:

score: 0
Accepted
time: 103ms
memory: 7044kb

input:

58

output:

1 9 0
1 9 1
2 7 1
3 5 1
4 3 1
6 4 1
5 2 1
3 1 1
3 1 0
5 2 0
7 1 0
7 1 1
6 3 1
8 4 1
6 5 1
4 4 1
5 6 1
4 8 1
3 10 1
5 9 1
4 11 1
2 12 1
1 10 1
3 9 1
2 11 1
2 11 0
3 13 0
2 15 0
1 17 0
2 19 0
2 19 1
1 21 1
1 21 0
3 20 0
5 21 0
6 23 0
8 22 0
6 21 0
7 23 0
5 22 0
5 22 1
4 24 1
5 26 1
6 28 1
7 30 1
8 32 ...

result:

ok good job

Test #29:

score: 0
Accepted
time: 109ms
memory: 7308kb

input:

60

output:

1 9 0
3 10 0
5 9 0
4 7 0
3 5 0
1 4 0
2 2 0
2 2 1
1 4 1
3 3 1
2 1 1
1 3 1
3 4 1
4 2 1
2 3 1
4 4 1
3 2 1
3 2 0
4 4 0
6 5 0
7 7 0
6 9 0
5 11 0
6 13 0
6 13 1
5 11 1
4 9 1
6 8 1
7 6 1
9 5 1
11 4 1
13 3 1
13 3 0
15 4 0
13 5 0
14 3 0
16 2 0
14 1 0
14 1 1
12 2 1
10 1 1
8 2 1
9 4 1
10 2 1
12 1 1
12 1 0
11 3 ...

result:

ok good job

Test #30:

score: 0
Accepted
time: 46ms
memory: 7196kb

input:

62

output:

1 9 0
2 11 0
1 13 0
2 15 0
1 17 0
3 16 0
2 18 0
1 20 0
1 20 1
2 18 1
1 16 1
3 15 1
5 14 1
4 16 1
3 18 1
3 18 0
2 20 0
2 20 1
4 19 1
6 18 1
8 17 1
9 19 1
11 18 1
12 20 1
14 21 1
15 19 1
16 17 1
15 15 1
13 14 1
12 16 1
12 16 0
14 15 0
13 13 0
12 11 0
11 9 0
9 8 0
10 10 0
9 12 0
8 14 0
10 15 0
10 15 1
...

result:

ok good job

Test #31:

score: 0
Accepted
time: 50ms
memory: 7592kb

input:

64

output:

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

result:

ok good job

Test #32:

score: 0
Accepted
time: 229ms
memory: 8124kb

input:

66

output:

1 9 0
2 11 0
3 9 0
4 11 0
3 13 0
1 12 0
2 14 0
1 16 0
3 17 0
4 15 0
5 17 0
5 17 1
4 19 1
2 18 1
1 20 1
3 19 1
2 17 1
1 15 1
1 15 0
3 16 0
4 18 0
6 19 0
5 21 0
7 20 0
9 21 0
11 20 0
12 22 0
10 23 0
10 23 1
8 24 1
8 24 0
6 25 0
4 26 0
3 28 0
5 29 0
3 30 0
1 29 0
1 29 1
3 30 1
1 31 1
1 31 0
2 33 0
2 33...

result:

ok good job

Test #33:

score: 0
Accepted
time: 281ms
memory: 8600kb

input:

68

output:

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

result:

ok good job

Test #34:

score: 0
Accepted
time: 183ms
memory: 8496kb

input:

70

output:

1 9 0
2 7 0
3 5 0
2 3 0
1 5 0
3 6 0
2 8 0
1 10 0
2 12 0
4 13 0
5 15 0
3 14 0
1 13 0
2 11 0
3 9 0
5 8 0
7 9 0
5 10 0
4 8 0
3 10 0
5 9 0
4 7 0
6 6 0
5 4 0
4 6 0
3 8 0
2 6 0
2 6 1
1 8 1
2 10 1
4 11 1
4 11 0
2 10 0
1 8 0
3 7 0
1 6 0
2 4 0
4 5 0
4 5 1
2 4 1
3 6 1
5 5 1
4 7 1
3 9 1
1 10 1
2 8 1
1 6 1
3 7 ...

result:

ok good job

Test #35:

score: 0
Accepted
time: 66ms
memory: 8616kb

input:

72

output:

1 9 0
3 10 0
2 8 0
1 6 0
1 6 1
2 8 1
3 10 1
1 11 1
2 13 1
1 15 1
3 14 1
2 12 1
4 13 1
6 14 1
5 12 1
7 13 1
8 15 1
8 15 0
9 13 0
8 11 0
9 9 0
8 7 0
7 9 0
7 9 1
8 11 1
10 10 1
9 12 1
11 13 1
12 11 1
13 9 1
11 10 1
13 11 1
15 12 1
14 14 1
15 16 1
13 17 1
13 17 0
15 18 0
16 20 0
17 22 0
15 23 0
14 25 0
...

result:

ok good job

Test #36:

score: 0
Accepted
time: 56ms
memory: 8956kb

input:

74

output:

1 9 0
1 9 1
2 11 1
2 11 0
3 13 0
4 11 0
3 9 0
1 8 0
1 8 1
3 9 1
5 8 1
3 7 1
4 5 1
4 5 0
2 4 0
1 2 0
3 3 0
1 4 0
1 4 1
2 6 1
3 8 1
2 10 1
4 11 1
6 10 1
8 11 1
10 10 1
11 8 1
10 6 1
10 6 0
9 8 0
11 9 0
13 10 0
15 9 0
13 8 0
15 7 0
17 8 0
18 6 0
16 5 0
17 7 0
19 6 0
19 6 1
21 7 1
19 8 1
20 10 1
22 9 1
...

result:

ok good job

Test #37:

score: 0
Accepted
time: 57ms
memory: 9420kb

input:

76

output:

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

result:

ok good job

Test #38:

score: 0
Accepted
time: 65ms
memory: 9528kb

input:

78

output:

1 9 0
1 9 1
2 7 1
1 5 1
3 6 1
1 7 1
2 9 1
4 8 1
6 9 1
6 9 0
5 7 0
4 9 0
2 8 0
3 6 0
1 7 0
2 9 0
3 7 0
4 5 0
4 5 1
5 7 1
3 8 1
2 10 1
4 11 1
6 10 1
8 11 1
10 12 1
9 10 1
8 8 1
8 8 0
9 10 0
10 12 0
8 13 0
9 11 0
11 12 0
12 14 0
11 16 0
13 15 0
14 13 0
14 13 1
15 15 1
13 16 1
12 18 1
10 19 1
11 21 1
12...

result:

ok good job

Test #39:

score: 0
Accepted
time: 275ms
memory: 10124kb

input:

80

output:

1 9 0
2 7 0
4 8 0
2 9 0
3 11 0
4 9 0
5 11 0
3 12 0
5 13 0
6 15 0
8 16 0
9 14 0
9 14 1
10 12 1
9 10 1
7 9 1
5 8 1
5 8 0
4 10 0
3 8 0
2 10 0
1 12 0
1 12 1
2 14 1
2 14 0
4 13 0
6 14 0
6 14 1
7 16 1
6 18 1
4 19 1
2 20 1
4 21 1
5 23 1
6 25 1
4 26 1
5 28 1
3 29 1
4 27 1
2 26 1
4 25 1
3 23 1
5 22 1
6 24 1
...

result:

ok good job

Test #40:

score: 0
Accepted
time: 82ms
memory: 10232kb

input:

82

output:

1 9 0
2 7 0
3 5 0
1 4 0
1 4 1
2 6 1
4 7 1
4 7 0
2 6 0
4 5 0
6 4 0
7 2 0
9 3 0
11 2 0
12 4 0
14 5 0
12 6 0
10 7 0
9 9 0
9 9 1
7 8 1
5 7 1
3 6 1
1 5 1
1 5 0
3 4 0
4 6 0
4 6 1
6 7 1
6 7 0
4 8 0
5 6 0
7 7 0
9 8 0
10 6 0
12 7 0
10 8 0
11 10 0
13 9 0
13 9 1
12 11 1
10 10 1
11 8 1
9 7 1
7 6 1
8 4 1
6 5 1
4...

result:

ok good job

Test #41:

score: 0
Accepted
time: 93ms
memory: 10480kb

input:

84

output:

1 9 0
2 11 0
1 13 0
1 13 1
3 12 1
3 12 0
2 14 0
2 14 1
1 12 1
1 12 0
3 13 0
1 14 0
1 14 1
3 15 1
2 17 1
4 16 1
2 15 1
3 13 1
2 11 1
4 12 1
4 12 0
5 14 0
7 15 0
8 17 0
6 16 0
6 16 1
8 17 1
7 15 1
5 16 1
5 16 0
4 18 0
2 19 0
1 21 0
2 23 0
3 25 0
4 27 0
2 28 0
1 26 0
1 26 1
3 27 1
5 28 1
5 28 0
4 30 0
...

result:

ok good job

Test #42:

score: 0
Accepted
time: 68ms
memory: 10924kb

input:

86

output:

1 9 0
1 9 1
2 11 1
2 11 0
3 13 0
4 11 0
3 9 0
4 7 0
5 5 0
7 4 0
6 2 0
8 1 0
8 1 1
10 2 1
12 1 1
12 1 0
11 3 0
9 2 0
11 1 0
11 1 1
12 3 1
14 2 1
14 2 0
16 1 0
15 3 0
14 1 0
13 3 0
14 5 0
12 6 0
10 5 0
12 4 0
11 2 0
9 1 0
9 1 1
7 2 1
6 4 1
4 3 1
5 1 1
5 1 0
6 3 0
8 4 0
7 2 0
9 3 0
10 1 0
12 2 0
10 3 0...

result:

ok good job

Test #43:

score: 0
Accepted
time: 248ms
memory: 11304kb

input:

88

output:

1 9 0
1 9 1
3 10 1
4 12 1
2 11 1
3 13 1
1 14 1
1 14 0
3 15 0
2 17 0
1 19 0
2 21 0
1 23 0
3 24 0
1 25 0
1 25 1
2 27 1
1 29 1
2 31 1
3 29 1
4 31 1
4 31 0
5 33 0
3 34 0
5 35 0
7 34 0
8 36 0
9 34 0
9 34 1
11 35 1
13 36 1
15 35 1
16 37 1
17 35 1
19 34 1
21 35 1
20 37 1
18 36 1
19 38 1
20 40 1
20 40 0
19 ...

result:

ok good job

Test #44:

score: 0
Accepted
time: 282ms
memory: 11488kb

input:

90

output:

1 9 0
2 7 0
1 5 0
2 3 0
2 3 1
1 5 1
3 4 1
4 6 1
2 7 1
1 9 1
3 10 1
4 8 1
4 8 0
3 10 0
1 11 0
1 11 1
3 12 1
2 10 1
3 8 1
1 7 1
1 7 0
2 9 0
4 10 0
5 8 0
5 8 1
7 7 1
8 9 1
10 10 1
11 12 1
13 13 1
11 14 1
10 12 1
12 11 1
12 11 0
13 9 0
15 8 0
13 7 0
11 8 0
10 6 0
8 5 0
6 6 0
8 7 0
9 5 0
10 7 0
12 6 0
14...

result:

ok good job

Test #45:

score: 0
Accepted
time: 124ms
memory: 11920kb

input:

92

output:

1 9 0
2 11 0
1 13 0
2 15 0
4 16 0
5 18 0
7 17 0
5 16 0
3 17 0
4 19 0
2 20 0
3 22 0
5 21 0
6 23 0
7 21 0
7 21 1
9 22 1
8 24 1
6 23 1
4 24 1
3 26 1
5 27 1
4 25 1
5 23 1
3 24 1
2 26 1
1 28 1
1 28 0
3 27 0
2 25 0
1 23 0
1 23 1
2 25 1
3 27 1
2 29 1
2 29 0
1 27 0
1 27 1
3 28 1
5 29 1
4 31 1
3 33 1
5 32 1
...

result:

ok good job

Test #46:

score: 0
Accepted
time: 293ms
memory: 12476kb

input:

94

output:

1 9 0
3 8 0
5 7 0
6 5 0
6 5 1
7 3 1
5 2 1
3 3 1
4 1 1
4 1 0
2 2 0
3 4 0
3 4 1
2 2 1
1 4 1
1 4 0
3 3 0
1 2 0
1 2 1
2 4 1
3 6 1
1 5 1
2 3 1
3 1 1
4 3 1
5 5 1
6 3 1
4 4 1
2 5 1
2 5 0
4 4 0
3 2 0
3 2 1
1 3 1
1 3 0
2 1 0
2 1 1
4 2 1
6 1 1
5 3 1
4 5 1
3 7 1
2 9 1
1 7 1
1 7 0
2 9 0
3 11 0
2 13 0
1 15 0
1 1...

result:

ok good job

Test #47:

score: 0
Accepted
time: 500ms
memory: 13528kb

input:

96

output:

1 9 0
2 11 0
4 12 0
6 13 0
6 13 1
8 14 1
7 12 1
9 11 1
7 10 1
9 9 1
8 7 1
6 8 1
7 6 1
8 8 1
6 7 1
5 5 1
3 6 1
1 5 1
2 3 1
4 4 1
5 2 1
3 1 1
3 1 0
1 2 0
1 2 1
2 4 1
1 6 1
2 8 1
2 8 0
1 6 0
3 5 0
2 3 0
4 4 0
3 6 0
2 4 0
4 5 0
6 6 0
8 5 0
10 4 0
11 2 0
13 3 0
11 4 0
9 3 0
8 1 0
7 3 0
9 2 0
7 1 0
5 2 0
...

result:

ok good job

Test #48:

score: 0
Accepted
time: 134ms
memory: 13320kb

input:

98

output:

1 9 0
2 7 0
2 7 1
3 5 1
5 6 1
4 4 1
2 3 1
3 1 1
1 2 1
1 2 0
3 1 0
4 3 0
2 2 0
3 4 0
5 3 0
3 2 0
4 4 0
2 3 0
1 5 0
1 5 1
3 4 1
1 3 1
2 5 1
1 7 1
3 8 1
4 6 1
4 6 0
3 8 0
4 10 0
5 8 0
3 9 0
4 11 0
3 13 0
2 15 0
4 14 0
2 13 0
1 11 0
1 11 1
2 13 1
1 15 1
3 14 1
2 16 1
4 17 1
5 15 1
4 13 1
2 12 1
1 10 1
3...

result:

ok good job

Test #49:

score: 0
Accepted
time: 166ms
memory: 13592kb

input:

100

output:

1 9 0
2 7 0
4 8 0
2 9 0
1 11 0
2 13 0
3 11 0
1 10 0
1 10 1
3 11 1
2 13 1
1 11 1
3 12 1
5 11 1
4 9 1
2 8 1
4 7 1
5 5 1
4 3 1
5 1 1
5 1 0
7 2 0
6 4 0
4 3 0
2 2 0
1 4 0
2 6 0
3 4 0
4 2 0
2 3 0
1 5 0
3 6 0
1 7 0
1 7 1
2 9 1
4 10 1
6 9 1
8 8 1
10 7 1
11 5 1
13 6 1
12 8 1
14 7 1
15 9 1
16 7 1
18 6 1
17 4 ...

result:

ok good job