結果

問題 No.2929 Miracle Branch
ユーザー tnakao0123tnakao0123
提出日時 2024-10-14 15:50:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 995 bytes
コンパイル時間 1,015 ms
コンパイル使用メモリ 54,764 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-14 15:50:42
合計ジャッジ時間 8,052 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 4 ms
5,248 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 3 ms
5,248 KB
testcase_19 AC 2 ms
5,248 KB
testcase_20 AC 3 ms
5,248 KB
testcase_21 AC 4 ms
5,248 KB
testcase_22 WA -
testcase_23 AC 6 ms
5,248 KB
testcase_24 AC 14 ms
5,248 KB
testcase_25 WA -
testcase_26 AC 2 ms
5,248 KB
testcase_27 AC 2 ms
5,248 KB
testcase_28 AC 4 ms
5,248 KB
testcase_29 AC 4 ms
5,248 KB
testcase_30 AC 4 ms
5,248 KB
testcase_31 AC 4 ms
5,248 KB
testcase_32 AC 4 ms
5,248 KB
testcase_33 AC 3 ms
5,248 KB
testcase_34 AC 41 ms
5,248 KB
testcase_35 AC 41 ms
5,248 KB
testcase_36 AC 3 ms
5,248 KB
testcase_37 AC 41 ms
5,248 KB
testcase_38 AC 42 ms
5,248 KB
testcase_39 AC 41 ms
5,248 KB
testcase_40 AC 40 ms
5,248 KB
testcase_41 AC 41 ms
5,248 KB
testcase_42 AC 40 ms
5,248 KB
testcase_43 AC 42 ms
5,248 KB
testcase_44 AC 42 ms
5,248 KB
testcase_45 AC 4 ms
5,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2929.cc:  No.2929 Miracle Branch - yukicoder
 */

#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

using ll = long long;
using vi = vector<int>;

/* global variables */

/* subroutines */

/* main */

int main() {
  ll x;
  scanf("%lld", &x);

  vi vs;
  if (x <= 4) vs.push_back(x);
  else {
    for (int i = 2; x > 1 && i <= MAX_N; i++)
      while (x % i == 0)
	vs.push_back(i), x /= i;
    if (x > 1) { puts("-1"); return 0; }
  }

  ll sum = 0;
  for (auto v: vs) sum += v + 1;
  if (sum > MAX_N) { puts("-1"); return 0; }

  int m = vs.size(), n = sum;

  printf("%d\n", n);
  for (int i = 0; i + 1 < m; i++) printf("%d %d\n", i + 1, i + 2);
  for (int i = 0, k = m; i < m; i++)
    for (int j = 0; j < vs[i]; j++)
      printf("%d %d\n", i + 1, (k++) + 1);
  for (int i = 0; i < n; i++)
    printf("%c%c", (i < m) ? 'b' : 'g', (i + 1 < n) ? ' ' : '\n');
  
  return 0;
}
0