結果
問題 | No.873 バイナリ、ヤバいなり!w |
ユーザー |
|
提出日時 | 2019-08-30 22:06:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,185 bytes |
コンパイル時間 | 2,234 ms |
コンパイル使用メモリ | 173,852 KB |
実行使用メモリ | 10,628 KB |
最終ジャッジ日時 | 2024-06-24 01:35:36 |
合計ジャッジ時間 | 4,647 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 WA * 14 |
ソースコード
#include <bits/stdc++.h>#include <vector>using namespace std;#define REP(i,n) for (int i=0;i<(n);i++)#define REP2(i,m,n) for (int i=m;i<(n);i++)typedef long long ll;int N;ll dp[303030];ll par[303030];ll par2[303030];void solve() {cin >> N;REP(i, N+1) dp[i] = 1LL << 59;dp[0] = 0;REP(i, N) for (ll j = 1; i + j * j <= N; ++j) {if (dp[i] + j <= dp[i + j * j]) {dp[i + j * j] = dp[i] + j;par[i + j * j] = i;par2[i + j * j] = j;}}vector<int> odd;vector<int> even;for (ll i = N; i > 0; ) {if (par2[i] % 2 == 0) {even.push_back(par2[i]);} else {odd.push_back(par2[i]);}i = par[i];}sort(odd.begin(), odd.end());sort(even.begin(), even.end());int v = 0;for (auto x: odd) {REP(_, x) {cout << v;v ^= 1;}v ^= 1;}for (auto x: even) {REP(_, x) {cout << v;v ^= 1;}v ^= 1;}cout << "\n";}int main() {cin.tie(0);ios::sync_with_stdio(false);solve();}