結果

問題 No.2256 Step by Step
ユーザー Xiaohuba
提出日時 2025-05-24 22:03:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 4,253 bytes
コンパイル時間 1,907 ms
コンパイル使用メモリ 193,340 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-05-24 22:03:16
合計ジャッジ時間 3,780 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

// #define LOCK_GETCHAR
// #define USE_INT_128
// #undef DEBUG

#ifdef DEBUG
#include <moeebius/debug.hpp>
#else
#define debug(...) (void(0))
#define Debug(...) (void(0))
#endif

#define ENABLE_IF_INT , enable_if_t<_is_integer<T>, int> = 0
template <class T> constexpr bool _is_integer = numeric_limits<T>::is_integer;
template <> constexpr bool _is_integer<bool> = false;
template <> constexpr bool _is_integer<char> = false;
#ifdef USE_INT_128
template <> constexpr bool _is_integer<__int128> = true;
template <> constexpr bool _is_integer<__uint128_t> = true;
#endif

#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(LOCK_GETCHAR)
#define getchar getchar_unlocked
#endif

#define il inline
#define mkp make_pair
#define fi first
#define se second
#define ssz(x) (signed((x).size()))
#define beg2ed(x) (x).begin(), (x).end()
#define _loop_i_t(j, k) make_signed_t<decltype((j) - (k))>
#define For(i, j, k) for (_loop_i_t(j, k) i = (j); i <= (k); ++i)
#define ForDown(i, j, k) for (_loop_i_t(j, k) i = (j); i >= decltype(i)(k); --i)
#define eb emplace_back
#ifndef ONLINE_JUDGE
#define FileIO(filename)                                                       \
  freopen(filename ".in", "r", stdin);                                         \
  freopen(filename ".out", "w", stdout)
#else
#define FileIO(filename) void(0)
#endif

using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
using db = double;
using ldb = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#ifdef USE_INT_128
using lll = __int128_t;
using ulll = __uint128_t;
#endif

// clang-format off
constexpr il ll qpow(ll x, ull y, ll mod){ ll ans = 1; x %= mod; while (y) { if (y & 1) (ans *= x) %= mod; (x *= x) %= mod; y >>= 1; } return ans; }
template<typename T> constexpr il void cmin(T & x, const T &y){ x = min(x, y); }
template<typename T> constexpr il void cmax(T & x, const T &y){ x = max(x, y); }
template<typename T ENABLE_IF_INT> il void read(T &x){ x = 0; int f = 1; int c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { x = x * 10 + (c - '0'); c = getchar(); } x *= f; }
template<typename T, typename ... Args> il void read(T &x, Args &... y){ read(x), read(y...); }
// clang-format on

// File head end

namespace {
// constexpr ll MAXN = ...;
int n;
void Main() {
  read(n);
  if (n == 1) {
    puts(R"*(1
2
2
2
1
1)*");
  } else if (n == 2) {
    puts("-1");
  } else if (n == 3) {
    puts(R"*(012
345
345
225
141
300)*");
  } else if (n == 4) {
    puts(R"*(4551
3662
6777
3005
3442
0112)*");
  } else {
    cout << "512";
    for (int i = 4; i + 3 <= n - 2; i += 4)
      cout << "3017";
    if (n % 4 == 1)
      cout << "03\n";
    else if (n % 4 == 2)
      cout << "336\n";
    else if (n % 4 == 3)
      cout << "3021\n";
    else
      cout << "66812\n";

    cout << "075";
    for (int i = 4; i + 3 <= n - 2; i += 4)
      cout << "4525";
    if (n % 4 == 1)
      cout << "61\n";
    else if (n % 4 == 2)
      cout << "669\n";
    else if (n % 4 == 3)
      cout << "9564\n";
    else
      cout << "00508\n";

    cout << "071";
    for (int i = 4; i + 3 <= n - 2; i += 4)
      cout << "4621";
    if (n % 4 == 1)
      cout << "61\n";
    else if (n % 4 == 2)
      cout << "881\n";
    else if (n % 4 == 3)
      cout << "9264\n";
    else
      cout << "33608\n";

    cout << "22";
    for (int i = 4; i + 3 <= n - 2; i += 4)
      cout << "6677";
    if (n % 4 == 1)
      cout << "444\n";
    else if (n % 4 == 2)
      cout << "4448\n";
    else if (n % 4 == 3)
      cout << "44455\n";
    else
      cout << "399155\n";

    cout << "05";
    for (int i = 4; i + 3 <= n - 2; i += 4)
      cout << "3435";
    if (n % 4 == 1)
      cout << "331\n";
    else if (n % 4 == 2)
      cout << "3001\n";
    else if (n % 4 == 3)
      cout << "39362\n";
    else
      cout << "444901\n";

    cout << "17";
    for (int i = 4; i + 3 <= n - 2; i += 4)
      cout << "0012";
    if (n % 4 == 1)
      cout << "060\n";
    else if (n % 4 == 2)
      cout << "0991\n";
    else if (n % 4 == 3)
      cout << "00114\n";
    else
      cout << "088228\n";
  }
}
} // namespace

signed main() { return Main(), 0; }
0