結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー risujirohrisujiroh
提出日時 2019-08-30 21:48:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 872 bytes
コンパイル時間 1,637 ms
コンパイル使用メモリ 171,280 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-06 06:46:16
合計ジャッジ時間 3,706 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 85 ms
4,380 KB
testcase_03 AC 69 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 18 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 6 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 4 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 12 ms
4,376 KB
testcase_35 AC 87 ms
4,380 KB
testcase_36 AC 46 ms
4,376 KB
testcase_37 AC 87 ms
4,500 KB
testcase_38 AC 88 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> dp(n + 1, 1e9);
  dp[0] = 0;
  for (int i = 1; i * i <= n; ++i) {
    for (int x = 0; x + i * i <= n; ++x) {
      dp[x + i * i] = min(dp[x + i * i], dp[x] + i);
    }
  }
  V<> v;
  while (n) {
    for (int i = 1; ; ++i) if (dp[n] == dp[n - i * i] + i) {
      v.push_back(i);
      n -= i * i;
      break;
    }
  }
  sort(begin(v), end(v), [&](int a, int b) {
    return make_pair(~a & 1, a & 1 ? a : -a) < make_pair(~b & 1, b & 1 ? b : -b);
  });
  n = v.size();
  int t = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < v[i]; ++j) {
      cout << (t + j & 1);
    }
    t += v[i] + 1;
  }
  cout << '\n';
}
0