結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー pekempeypekempey
提出日時 2019-08-30 21:53:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,097 bytes
コンパイル時間 1,588 ms
コンパイル使用メモリ 170,048 KB
実行使用メモリ 5,600 KB
最終ジャッジ日時 2023-09-06 06:46:40
合計ジャッジ時間 4,487 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int N; cin >> N;
  vector<int> dp(N + 1, 1e9);
  vector<int> ep(N + 1, -1);
  dp[0] = 0;
  for (int i = 1; i * i <= N; i += 2) {
    for (int j = 0; j + i * i <= N; j++) {
      if (dp[j + i * i] > dp[j] + i) {
        dp[j + i * i] = dp[j] + i;
        ep[j + i * i] = i;
      }
    }
  }
  for (int i = 600; i >= 1; i--) {
    for (int j = 0; j + i * i <= N; j++) {
      if (dp[j + i * i] > dp[j] + i) {
        dp[j + i * i] = dp[j] + i;
        ep[j + i * i] = i;
      }
    }
  }
  vector<int> seq;
  int i = N;
  while (i != 0) {
    seq.push_back(ep[i]);
    i -= ep[i] * ep[i];
  }
  reverse(range(seq));
  string ans;
  for (int k : seq) {
    char c = ans.empty() ? '0' : ans.back();
    rep(_, k) {
      ans += c;
      c ^= '0' ^ '1';
    }
  }
  cout << ans << endl;
}
0