結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー pirozhkipirozhki
提出日時 2019-10-14 07:27:52
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 890 bytes
コンパイル時間 1,401 ms
コンパイル使用メモリ 89,016 KB
実行使用メモリ 5,548 KB
最終ジャッジ日時 2023-08-24 17:15:54
合計ジャッジ時間 13,842 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 520 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 1,143 ms
5,484 KB
testcase_03 AC 920 ms
4,964 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 244 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 61 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 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,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 32 ms
4,376 KB
testcase_33 AC 6 ms
4,376 KB
testcase_34 AC 146 ms
4,380 KB
testcase_35 AC 1,268 ms
5,356 KB
testcase_36 AC 629 ms
4,644 KB
testcase_37 AC 1,218 ms
5,412 KB
testcase_38 AC 1,203 ms
5,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main() {
	int n; cin >> n;
	vector<pair<int,int>> table(n+1);
	for (int i = 1; i <= n; i++) {
		vector<pair<int, int>> v;
		int rt = static_cast<int>(sqrt(i));
		for (int j = 1; j <= rt; j += 2) {
			v.emplace_back(make_pair(j, j + table[i - j * j].second));
		}
		for (int j = rt - rt % 2; j > 0; j -= 2) {
			v.emplace_back(make_pair(j, j + table[i - j * j].second));
		}
		int k = distance(v.begin(), min_element(v.begin(), v.end(), [](auto a, auto b) { return a.second < b.second; }));
		table[i].first = v[k].first;
		table[i].second = table[i].first + table[i - table[i].first * table[i].first].second;
	}

	bool b = 0;
	for (int i = n; i > 0; i -= table[i].first*table[i].first) {
		for (int j = 0; j < table[i].first; j++) {
			cout << b;
			b ^= 1;
		}
		b ^= 1;
	}
	return 0;
}
0