結果

問題 No.2608 Divide into two
ユーザー forest3forest3
提出日時 2024-02-13 17:03:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 463 bytes
コンパイル時間 1,748 ms
コンパイル使用メモリ 167,652 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-13 17:03:05
合計ジャッジ時間 2,602 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
	int T;
	cin >> T;
	rep(i, T) {
		int N;
		cin >> N;
		int sum = N * (N + 1) / 2;
		if( sum % 2 ) cout << -1 << endl;
		else {
			sum /= 2;
			string s(N, '0');
			for(int j = N - 1; j >= 0; j--) {
				int n = j + 1;
				if(n <= sum) {
					s[j] = '1';
					sum -= n;
					if( sum == 0) break;
				}
			}
			cout << s << endl;
		}
	}
}
0