QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#600765#9432. Permutationucup-team987AC ✓296ms3928kbC++233.9kb2024-09-29 19:00:012024-09-29 19:00:02

Judging History

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

  • [2024-09-29 19:00:02]
  • 评测
  • 测评结果:AC
  • 用时:296ms
  • 内存:3928kb
  • [2024-09-29 19:00:01]
  • 提交

answer

#if __INCLUDE_LEVEL__ == 0

#include __BASE_FILE__

void Solve() {
  int n;
  IN(n);
  vector<int> a(n);
  auto Rec = [&](auto Rec, int L, int R, const vector<int>& v) -> void {
    if (L + 1 == R) {
      a[L] = v[0];
      return;
    }
    int M = midpoint(L, R);
    vector<int> vL, vR;
    queue<vector<int>> q;
    for (int e : v) {
      q.push({e});
    }
    while (Sz(q) >= 2) {
      auto x = q.front();
      q.pop();
      auto y = q.front();
      q.pop();
      vector<int> query(n, x[0]);
      fill(query.begin() + M, query.begin() + R, y[0]);
      OUT(0, query);
      int response;
      IN(response);
      if (response == 2) {
        vL.insert(vL.end(), ALL(x));
        vR.insert(vR.end(), ALL(y));
      } else if (response == 0) {
        vL.insert(vL.end(), ALL(y));
        vR.insert(vR.end(), ALL(x));
      } else {
        x.insert(x.end(), ALL(y));
        q.push(move(x));
      }
    }
    if (Sz(q) == 1) {
      for (int e : q.front()) {
        (Sz(vL) < Sz(vR) ? vL : vR).push_back(e);
      }
      q.pop();
    }
    Rec(Rec, L, M, vL);
    Rec(Rec, M, R, vR);
  };
  vector<int> v(ALL(Rep1(1, n)));
  Xorshift().Shuffle(v);
  Rec(Rec, 0, n, v);
  OUT(1, a);
}

int main() {
  ios::sync_with_stdio(false);

  Solve();
}

#elif __INCLUDE_LEVEL__ == 1

#include <bits/stdc++.h>

template <class T> concept Range = std::ranges::range<T> && !std::convertible_to<T, std::string_view>;
template <class T> concept Tuple = std::__is_tuple_like<T>::value && !Range<T>;

namespace std {

istream& operator>>(istream& is, Range auto&& r) {
  for (auto&& e : r) is >> e;
  return is;
}
istream& operator>>(istream& is, Tuple auto&& t) {
  apply([&](auto&... xs) { (is >> ... >> xs); }, t);
  return is;
}

ostream& operator<<(ostream& os, Range auto&& r) {
  auto sep = "";
  for (auto&& e : r) os << exchange(sep, " ") << e;
  return os;
}
ostream& operator<<(ostream& os, Tuple auto&& t) {
  auto sep = "";
  apply([&](auto&... xs) { ((os << exchange(sep, " ") << xs), ...); }, t);
  return os;
}

}  // namespace std

class Xorshift {
 public:
  Xorshift() : Xorshift(std::chrono::steady_clock::now().time_since_epoch().count()) {}

  explicit Xorshift(uint64_t seed) {
    std::ranges::generate(x_, std::mt19937_64(seed));
  }

  uint64_t Next() {
    if (++r_ == N) {
      r_ = 0;
      for (int i = 0; i < N; ++i) {
        x_[i] ^= x_[i] << 7;
        x_[i] ^= x_[i] >> 9;
      }
    }
    return x_[r_];
  }

  int Int(int a, int b) {
    uint64_t r = Next() >> 32;
    return a + int(r * (b - a + 1) >> 32);
  }

  int64_t Int(int64_t a, int64_t b) {
    __uint128_t r = Next();
    return a + int64_t(r * (b - a + 1) >> 64);
  }

  std::array<int, 2> Int2(int a, int b) {
    auto r = std::bit_cast<std::array<uint32_t, 2>>(Next());
    int x = a + int(r[0] * uint64_t(b - a) >> 32);
    int y = a + int(r[1] * uint64_t(b - a + 1) >> 32);
    if (y == x) {
      y = b;
    } else if (y < x) {
      std::swap(x, y);
    }
    return {x, y};
  }

  double Uniform() {
    return double(Next()) / double(UINT64_MAX);
  }

  double Uniform(double a, double b) {
    return a + Uniform() * (b - a);
  }

  template <std::ranges::random_access_range R>
  void Shuffle(R&& r) {
    int n = int(std::ranges::size(r));
    for (int i = 1; i < n; ++i) {
      if (int j = Int(0, i); j < i) {
        std::ranges::swap(r[i], r[j]);
      }
    }
  }

 private:
  static constexpr int N = 8;

  std::array<uint64_t, N> x_;
  int r_ = -1;
};

using namespace std;

#define ALL(r) begin(r), end(r)
#define Rep(...) [](int l, int r) { return views::iota(min(l, r), r); }(__VA_ARGS__)
#define Rep1(...) [](int l, int r) { return Rep(l, r + 1); }(__VA_ARGS__)
#define Sz(r) int(size(r))
#define IN(...) (cin >> forward_as_tuple(__VA_ARGS__))
#define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n')

#endif  // __INCLUDE_LEVEL__ == 1

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
1
2
2
0
1
2
0

output:

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

result:

ok Accepted

Test #2:

score: 0
Accepted
time: 271ms
memory: 3712kb

input:

1000
2
1
1
2
1
0
1
0
1
0
0
0
0
0
0
2
0
1
1
1
1
2
2
1
1
0
1
1
0
1
0
1
1
2
1
0
2
2
0
1
0
1
0
2
2
0
1
1
0
1
0
2
1
0
0
0
1
2
0
1
2
1
2
1
0
1
0
1
1
0
1
0
2
0
1
1
0
0
0
1
1
1
1
2
1
1
1
1
2
1
0
1
0
0
2
1
2
2
0
1
2
1
1
1
0
1
1
2
1
1
1
1
0
1
2
2
2
1
0
1
1
0
2
0
1
1
2
2
1
1
1
0
1
0
0
1
2
1
1
1
0
1
1
1
1
2
1
0...

output:

0 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 100...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1

result:

ok Accepted

Test #4:

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

input:

2
2

output:

0 2 1
1 2 1

result:

ok Accepted

Test #5:

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

input:

3
0
0

output:

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

result:

ok Accepted

Test #6:

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

input:

4
2
0
2
2

output:

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

result:

ok Accepted

Test #7:

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

input:

6
2
2
0
1
2
0
0
2

output:

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

result:

ok Accepted

Test #8:

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

input:

7
0
1
2
2
0
0
2
2
2
2

output:

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

result:

ok Accepted

Test #9:

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

input:

8
2
1
0
1
0
0
2
2
0
0
2
2
0

output:

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

result:

ok Accepted

Test #10:

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

input:

9
1
1
2
2
0
2
0
0
2
2
2
2
2
0

output:

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

result:

ok Accepted

Test #11:

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

input:

10
0
1
2
2
1
2
2
0
2
1
2
0
1
1
0
2
1
2
0

output:

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

result:

ok Accepted

Test #12:

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

input:

11
2
1
1
1
1
1
1
1
2
2
1
2
0
0
2
1
1
2
2
0
0
2
0

output:

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

result:

ok Accepted

Test #13:

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

input:

12
0
2
1
1
1
1
1
1
2
2
0
0
0
0
2
2
1
1
0
0
1
2
0
0
0

output:

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

result:

ok Accepted

Test #14:

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

input:

13
1
1
0
2
0
0
1
2
1
2
1
0
0
0
1
2
2
1
1
0
0
0
2
1
1
2
2
2

output:

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

result:

ok Accepted

Test #15:

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

input:

14
2
1
1
1
1
2
2
2
2
2
1
0
2
0
2
2
2
0
2
0
0
1
2
0
0
2
0
2
0

output:

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

result:

ok Accepted

Test #16:

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

input:

15
0
0
0
1
2
1
0
1
2
2
0
1
2
2
2
2
0
2
0
0
2
0
2
0
0
0
2
2
2
0
0

output:

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

result:

ok Accepted

Test #17:

score: 0
Accepted
time: 264ms
memory: 3700kb

input:

975
1
1
2
1
2
0
2
2
1
2
2
0
2
1
0
0
1
0
1
1
2
1
0
1
1
1
1
1
0
0
1
2
2
1
2
2
1
2
1
2
0
2
1
2
1
0
1
2
1
1
0
2
1
2
0
1
2
1
2
2
1
1
0
0
2
0
2
0
2
2
0
1
0
0
2
2
1
1
1
1
0
1
0
1
2
2
1
2
0
0
0
2
2
1
0
2
1
1
2
1
2
1
1
2
1
2
2
2
0
0
1
1
1
1
1
1
1
1
1
0
1
2
1
2
1
1
0
2
1
1
1
1
1
0
1
2
1
0
2
2
2
1
0
2
0
1
0
1
...

output:

0 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 26...

result:

ok Accepted

Test #18:

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

input:

976
0
0
1
1
0
1
1
0
2
0
2
2
1
1
0
1
0
1
0
2
1
2
2
1
1
0
0
1
0
1
1
0
1
1
0
2
0
0
2
0
0
1
0
0
2
1
2
1
2
2
1
0
1
2
2
1
0
2
2
2
0
1
2
1
0
2
0
2
1
2
2
1
1
2
1
0
0
1
0
2
0
1
1
1
1
0
0
0
1
1
1
1
2
2
1
1
1
1
0
2
1
1
2
1
0
2
1
0
0
2
1
0
0
1
1
1
2
0
2
1
1
0
1
0
2
2
1
0
2
2
1
0
1
1
1
1
1
2
1
2
1
1
1
0
1
0
2
1
...

output:

0 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 70...

result:

ok Accepted

Test #19:

score: 0
Accepted
time: 285ms
memory: 3760kb

input:

977
2
0
1
1
0
1
1
0
2
0
1
1
1
1
1
0
2
1
1
2
1
2
1
1
1
1
1
0
2
2
1
0
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
0
0
1
0
1
1
1
0
1
0
2
1
1
0
2
2
0
2
1
2
0
0
0
0
0
1
1
1
2
1
2
2
1
1
1
2
1
0
0
1
1
2
1
1
1
1
2
2
1
0
2
2
1
1
1
1
0
1
2
1
1
1
1
2
0
1
0
1
1
0
1
2
0
2
2
0
1
0
1
1
0
0
1
0
2
0
0
0
1
2
1
2
1
1
0
1
1
0
...

output:

0 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 1...

result:

ok Accepted

Test #20:

score: 0
Accepted
time: 280ms
memory: 3776kb

input:

978
2
0
0
1
1
1
2
2
1
2
1
0
0
2
1
0
1
1
1
2
1
0
1
1
0
1
1
1
2
1
2
0
1
1
1
2
1
1
2
2
2
2
2
1
1
1
2
0
0
2
1
1
1
2
1
1
1
1
2
1
1
0
1
0
2
2
2
1
0
2
1
1
1
1
0
0
0
2
0
0
0
2
1
2
1
2
1
0
2
1
1
0
2
2
2
1
1
0
2
1
1
0
2
0
1
2
0
1
0
0
1
0
1
0
2
1
1
1
1
1
1
1
1
1
1
0
2
2
1
0
1
1
1
1
1
1
1
1
0
0
1
1
0
2
1
0
1
2
...

output:

0 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 710 71...

result:

ok Accepted

Test #21:

score: 0
Accepted
time: 277ms
memory: 3648kb

input:

979
1
0
1
2
1
2
0
1
1
1
1
1
1
1
2
1
0
1
1
2
1
1
1
1
0
2
2
0
1
2
1
1
1
1
2
0
1
1
2
1
2
1
1
1
0
1
0
1
2
0
0
1
1
1
1
2
2
1
1
2
0
2
1
1
2
1
1
2
2
1
1
2
0
2
2
2
1
1
0
0
0
1
0
0
2
0
1
0
1
0
1
2
1
1
0
2
1
1
0
2
2
0
0
1
1
1
0
0
1
0
0
2
1
0
2
0
1
1
2
1
0
2
2
1
1
1
1
1
1
1
1
2
2
1
2
1
1
1
0
2
1
1
2
1
1
1
2
1
...

output:

0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

result:

ok Accepted

Test #22:

score: 0
Accepted
time: 296ms
memory: 3704kb

input:

980
0
1
2
0
0
1
2
1
1
2
1
1
1
0
1
0
1
0
2
0
1
0
2
1
2
1
2
1
1
1
0
1
0
1
1
1
1
1
1
0
0
0
1
2
1
0
0
1
1
1
1
2
2
0
0
0
0
1
2
1
1
0
1
1
1
2
0
1
1
2
2
1
2
1
0
1
0
1
0
1
2
1
1
0
1
1
0
2
1
2
2
1
0
0
2
1
1
1
2
1
1
2
2
2
1
1
1
0
2
2
1
1
1
0
0
1
0
1
1
1
0
1
0
1
1
1
1
2
0
1
1
1
1
1
1
0
0
2
2
1
1
1
2
2
1
0
1
1
...

output:

0 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 25...

result:

ok Accepted

Test #23:

score: 0
Accepted
time: 262ms
memory: 3864kb

input:

981
1
0
2
1
1
1
1
1
1
2
0
1
1
0
0
1
2
0
1
1
1
2
2
0
1
0
0
0
2
1
0
2
1
1
2
1
1
1
1
1
1
1
1
2
1
2
1
0
2
0
0
1
1
1
1
1
0
1
1
0
1
2
1
2
1
0
1
0
2
1
0
0
0
0
0
1
2
1
2
0
1
0
1
2
1
2
1
1
0
0
1
0
1
2
2
1
2
1
2
0
1
2
1
0
1
0
2
2
0
0
2
1
0
0
1
0
1
1
1
2
1
1
0
2
1
0
2
1
1
1
2
2
2
1
2
1
2
1
2
0
1
0
2
0
1
0
0
1
...

output:

0 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 70...

result:

ok Accepted

Test #24:

score: 0
Accepted
time: 278ms
memory: 3740kb

input:

982
1
1
1
0
2
1
1
0
1
0
0
1
0
2
1
1
0
1
2
0
1
0
1
0
2
1
0
0
1
0
2
1
0
0
0
2
0
2
1
0
1
0
2
1
1
1
0
0
0
2
0
1
0
1
0
1
0
1
2
1
2
1
1
1
1
0
0
2
0
1
0
1
1
1
0
0
1
1
2
1
0
0
2
1
1
1
1
1
0
1
1
1
1
1
0
1
2
1
1
0
0
1
1
2
2
1
2
1
2
0
2
1
1
1
2
1
1
2
1
2
1
1
2
1
1
0
2
1
2
1
1
1
2
1
1
2
1
0
0
1
2
0
2
2
2
1
1
1
...

output:

0 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 406 40...

result:

ok Accepted

Test #25:

score: 0
Accepted
time: 270ms
memory: 3680kb

input:

983
1
1
1
2
1
1
2
0
0
1
1
0
1
1
0
0
2
0
1
1
1
2
0
1
1
1
2
0
0
1
0
1
2
1
1
2
1
1
0
1
0
2
0
1
2
1
2
1
1
2
1
2
2
1
2
1
1
2
2
1
2
0
1
0
0
2
2
1
1
2
2
1
0
0
2
1
0
1
0
1
2
1
1
0
1
1
1
1
1
1
0
1
1
2
0
0
1
1
2
0
2
1
0
2
1
1
1
1
1
1
0
0
2
1
1
0
1
1
0
2
2
1
2
1
1
1
1
0
1
1
0
0
2
0
0
1
0
1
2
1
0
1
2
0
1
0
2
0
...

output:

0 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 78...

result:

ok Accepted

Test #26:

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

input:

984
0
2
2
2
2
0
0
1
0
0
1
0
2
2
0
1
1
1
0
2
1
1
1
0
1
1
0
2
0
0
2
1
0
0
1
1
2
0
1
1
1
2
2
0
2
0
0
0
1
1
1
2
0
1
2
1
1
1
1
2
0
2
1
1
1
1
0
1
0
1
1
0
0
1
1
1
1
2
1
1
2
2
1
1
2
0
1
1
1
2
0
1
1
2
2
1
1
1
1
1
0
1
2
0
0
1
0
1
0
0
0
1
1
2
2
2
0
0
2
2
0
2
1
1
2
1
1
0
1
1
1
1
0
0
1
1
2
1
0
1
2
1
1
1
1
2
0
2
...

output:

0 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 935 93...

result:

ok Accepted

Test #27:

score: 0
Accepted
time: 267ms
memory: 3764kb

input:

985
0
0
1
2
1
2
1
1
0
1
0
1
2
1
0
1
0
0
0
2
0
2
2
0
1
1
1
0
1
1
1
2
1
1
2
1
1
1
0
1
2
1
1
0
2
1
1
1
0
1
0
0
2
0
1
1
2
1
0
1
1
1
1
2
0
0
2
1
0
0
2
0
1
1
1
1
1
2
2
1
0
0
1
0
0
0
2
1
2
1
0
2
1
0
2
1
1
0
0
1
1
1
2
0
1
2
1
1
1
2
2
1
0
1
1
0
0
2
1
0
1
1
1
1
1
2
2
1
1
1
2
2
1
1
1
2
1
1
1
2
0
1
0
1
2
1
2
2
...

output:

0 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 60...

result:

ok Accepted

Test #28:

score: 0
Accepted
time: 279ms
memory: 3708kb

input:

986
1
1
1
2
1
1
2
0
0
0
1
1
2
2
0
1
2
2
1
1
0
2
2
0
2
1
1
1
0
0
1
1
0
1
1
2
0
2
1
1
0
1
1
0
0
2
0
2
2
2
1
2
0
1
1
1
1
1
1
1
1
1
2
0
1
1
1
2
2
1
2
1
1
2
1
0
1
1
1
0
1
2
1
1
1
0
1
1
0
2
1
0
2
2
1
2
1
0
1
1
2
2
1
0
0
1
1
1
0
1
0
1
1
1
1
1
0
1
0
0
0
0
1
1
1
2
1
0
1
2
2
1
0
1
1
1
2
1
0
2
1
0
1
2
1
2
2
0
...

output:

0 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 96...

result:

ok Accepted

Test #29:

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

input:

987
1
1
0
2
0
0
1
1
0
2
0
2
2
1
1
0
0
1
1
0
1
1
0
2
2
1
2
2
1
1
0
1
1
1
1
1
2
1
0
1
2
1
1
2
0
1
2
1
2
1
0
0
1
0
0
1
1
1
2
2
1
1
1
1
1
1
2
2
2
1
1
0
2
1
1
1
1
2
0
1
1
2
1
1
0
1
1
1
1
2
1
1
0
1
1
0
1
1
1
0
2
1
0
1
1
1
0
1
2
1
1
0
1
2
0
0
2
1
0
0
0
0
1
0
1
2
2
2
1
1
1
1
2
0
2
1
1
1
2
1
2
2
2
2
2
1
1
1
...

output:

0 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 34...

result:

ok Accepted

Test #30:

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

input:

988
2
1
0
1
1
2
1
1
2
2
0
2
0
1
1
0
1
2
0
1
1
1
0
1
1
1
1
0
1
2
0
1
0
1
1
0
1
2
1
1
2
0
2
2
0
1
0
1
2
1
2
1
1
2
1
1
2
1
1
2
2
1
1
2
0
1
0
2
2
1
1
1
1
1
1
1
1
1
1
0
1
2
1
1
1
0
2
0
1
0
1
1
2
0
2
1
2
1
2
2
0
1
2
1
1
1
2
2
1
1
1
0
1
2
1
1
1
2
1
2
2
1
2
0
0
1
0
2
1
1
0
1
1
1
0
1
0
1
2
2
1
2
1
1
1
1
1
2
...

output:

0 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 699 69...

result:

ok Accepted

Test #31:

score: 0
Accepted
time: 271ms
memory: 3708kb

input:

989
0
0
1
1
1
2
0
2
1
2
2
1
1
0
1
1
1
1
1
1
1
0
1
0
0
0
0
1
0
0
1
2
2
0
2
1
2
1
0
1
1
2
1
0
1
1
1
1
1
2
1
0
1
0
1
1
0
1
2
0
1
1
0
1
0
1
1
1
1
0
2
2
2
1
1
2
0
1
0
1
2
2
0
0
2
0
1
2
1
1
1
2
1
0
0
1
2
0
0
2
0
1
2
1
2
0
0
1
0
2
0
0
0
0
1
1
0
1
1
2
1
1
2
2
2
2
1
1
1
1
2
1
1
1
2
0
1
0
1
1
0
2
1
2
2
2
2
1
...

output:

0 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 924 92...

result:

ok Accepted

Test #32:

score: 0
Accepted
time: 278ms
memory: 3712kb

input:

990
2
1
1
2
1
1
0
2
1
1
1
1
1
0
1
0
1
1
1
1
2
2
2
2
1
0
1
0
1
1
2
0
1
1
1
1
0
1
1
0
1
1
1
1
1
0
0
0
1
1
0
0
0
2
2
0
1
1
1
1
2
2
1
1
1
2
0
0
1
1
1
1
0
1
1
1
1
2
1
0
2
1
2
1
2
1
0
1
0
1
1
0
1
0
1
1
2
1
1
1
0
1
1
2
1
1
1
1
1
2
2
0
0
0
1
1
0
2
1
0
0
1
1
1
1
1
2
0
0
2
1
1
2
2
0
2
0
1
2
1
1
1
1
2
0
2
2
1
...

output:

0 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 86...

result:

ok Accepted

Test #33:

score: 0
Accepted
time: 271ms
memory: 3656kb

input:

991
0
1
0
2
0
1
2
1
1
1
0
1
0
1
0
1
2
1
0
0
2
2
1
1
2
1
1
1
1
1
0
2
2
1
0
1
2
2
2
2
1
1
1
0
1
1
0
2
2
1
2
1
0
0
0
1
0
2
1
1
1
1
0
1
2
1
1
1
1
1
0
1
1
0
2
2
1
1
0
2
2
1
0
0
1
1
1
1
0
2
1
1
1
1
1
2
0
2
2
1
1
2
1
0
1
1
2
0
1
1
0
1
1
2
0
2
1
1
0
1
1
2
2
0
1
2
1
1
1
2
2
1
1
0
1
1
1
1
2
2
1
1
1
0
2
0
0
1
...

output:

0 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 23...

result:

ok Accepted

Test #34:

score: 0
Accepted
time: 246ms
memory: 3664kb

input:

992
1
2
1
1
0
1
2
2
1
1
1
0
1
0
1
2
0
0
1
1
1
2
1
0
1
1
1
1
1
1
2
1
0
1
1
1
1
0
1
1
1
0
2
1
1
1
1
0
1
1
0
1
2
1
0
0
2
1
1
0
1
0
1
0
1
0
1
1
0
1
1
2
2
1
2
1
1
2
0
1
1
2
1
1
1
1
0
1
2
2
1
2
1
1
1
1
1
1
0
2
0
1
0
2
0
1
2
1
1
2
1
1
1
2
1
1
2
2
1
1
1
0
0
0
1
1
1
1
0
1
1
0
1
1
1
0
2
1
2
0
0
1
1
2
1
1
1
1
...

output:

0 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 8...

result:

ok Accepted

Test #35:

score: 0
Accepted
time: 259ms
memory: 3708kb

input:

993
0
1
2
0
2
1
1
2
2
1
0
2
0
2
0
1
0
0
1
1
1
1
0
1
1
1
1
1
0
0
2
0
1
2
1
0
2
1
1
2
0
1
1
0
0
1
2
1
2
2
0
2
2
1
1
2
1
1
0
2
1
1
0
1
1
2
0
0
1
2
0
0
1
1
1
2
2
1
0
2
1
1
2
0
1
0
1
2
1
1
0
1
0
1
1
2
1
1
0
1
1
1
0
0
2
0
0
1
1
0
1
1
2
1
1
2
1
1
1
0
1
1
0
1
2
1
0
2
1
0
0
1
0
1
2
0
0
2
1
1
1
1
1
2
0
1
2
1
...

output:

0 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 88...

result:

ok Accepted

Test #36:

score: 0
Accepted
time: 244ms
memory: 3740kb

input:

994
1
1
2
1
0
1
1
1
1
2
2
1
0
0
0
2
1
1
0
1
2
1
1
0
1
1
2
2
1
1
1
1
0
1
1
2
2
2
0
1
1
1
1
2
1
2
1
1
0
1
1
1
2
1
0
1
0
2
2
2
1
1
1
2
0
1
2
1
0
1
2
1
1
1
0
1
2
2
1
1
1
1
1
1
0
1
1
1
0
0
2
1
2
1
0
1
0
0
1
1
0
1
1
1
1
0
0
1
1
1
1
2
2
2
1
1
2
1
0
0
0
2
1
0
0
1
1
1
0
0
0
1
2
0
1
0
1
1
1
2
2
1
1
1
1
1
1
1
...

output:

0 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 221 22...

result:

ok Accepted

Test #37:

score: 0
Accepted
time: 280ms
memory: 3652kb

input:

995
0
1
0
1
1
1
0
1
2
2
1
1
1
1
2
0
2
1
2
1
1
0
1
1
1
0
2
1
1
1
1
0
0
1
2
0
0
2
1
1
0
1
0
1
1
1
1
2
0
2
2
1
2
1
1
1
2
1
1
1
1
1
2
1
1
0
2
1
2
0
2
2
1
0
1
0
1
2
2
1
2
2
2
1
1
1
1
1
0
2
1
1
1
2
1
2
1
0
2
0
1
0
2
1
1
1
1
0
1
1
2
0
1
0
1
1
1
1
1
1
0
1
0
1
2
0
0
0
1
1
1
2
2
1
1
1
2
1
0
2
1
1
0
1
0
2
1
1
...

output:

0 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 43...

result:

ok Accepted

Test #38:

score: 0
Accepted
time: 251ms
memory: 3704kb

input:

996
0
1
0
1
1
2
1
1
0
1
2
0
2
1
1
1
2
0
2
0
1
1
1
1
1
2
0
1
2
1
0
1
1
0
1
1
2
2
0
0
2
2
1
1
0
1
0
1
1
0
1
1
0
0
2
0
2
1
1
1
0
0
2
2
1
0
1
2
0
0
1
0
1
1
0
0
1
1
1
1
1
2
2
1
2
1
1
1
2
2
1
2
2
1
1
1
1
0
0
0
0
2
2
1
0
1
2
1
1
2
1
0
0
0
1
2
2
2
1
2
0
0
1
2
1
2
1
0
0
1
1
2
1
2
1
1
1
1
0
1
1
0
0
2
1
1
0
1
...

output:

0 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 383 38...

result:

ok Accepted

Test #39:

score: 0
Accepted
time: 288ms
memory: 3928kb

input:

997
2
1
2
0
1
0
1
1
0
2
1
1
1
1
2
0
0
1
1
1
1
2
1
1
0
1
1
1
1
1
1
1
2
0
0
1
1
1
1
1
1
2
1
0
2
1
0
2
0
0
0
1
0
2
2
0
0
0
0
1
2
1
1
1
1
0
1
2
1
0
0
0
2
2
0
0
1
1
1
2
1
2
0
0
1
2
2
1
1
1
0
1
1
1
1
2
1
2
1
1
2
0
2
0
2
0
1
1
1
0
2
2
1
0
1
2
2
0
2
2
1
2
1
1
2
2
1
2
2
1
1
1
1
1
1
0
0
0
0
1
2
2
2
2
0
2
2
2
...

output:

0 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 773 77...

result:

ok Accepted

Test #40:

score: 0
Accepted
time: 290ms
memory: 3776kb

input:

998
1
1
2
1
1
1
0
1
1
0
0
0
2
1
1
1
2
2
0
1
1
1
0
2
1
1
1
1
0
2
1
0
0
1
2
0
1
2
1
2
1
2
1
1
2
1
1
0
1
1
2
0
1
1
2
2
1
0
1
1
1
1
2
1
1
1
1
1
0
0
1
1
1
1
2
0
1
1
0
2
1
1
2
0
0
1
0
2
0
2
0
1
1
0
2
1
2
0
1
1
0
2
1
1
0
2
1
0
2
1
1
0
2
0
0
2
2
0
1
1
1
1
0
1
1
1
0
1
1
1
1
1
1
0
2
1
1
2
1
1
1
0
1
1
0
1
1
2
...

output:

0 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 649 64...

result:

ok Accepted

Test #41:

score: 0
Accepted
time: 264ms
memory: 3760kb

input:

999
1
1
1
0
1
1
2
1
1
2
2
2
1
2
0
1
1
1
1
1
1
1
2
0
2
1
0
1
2
0
1
1
0
1
1
0
1
1
1
1
1
0
0
2
1
2
1
1
0
1
2
0
2
0
1
2
1
1
0
1
1
1
1
2
1
0
1
1
1
2
2
1
0
1
1
2
0
1
1
2
1
1
2
1
1
1
1
2
1
2
1
1
1
0
0
1
2
1
0
1
1
1
2
1
1
2
0
2
1
1
2
1
2
0
1
1
2
2
2
1
1
0
1
1
2
1
0
1
0
0
1
1
1
1
0
0
1
1
1
1
1
1
1
0
1
1
1
2
...

output:

0 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 767 76...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed