結果

問題 No.2608 Divide into two
ユーザー YwestbuilderkYwestbuilderk
提出日時 2024-01-22 19:00:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 506 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 77,368 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-22 19:00:15
合計ジャッジ時間 1,127 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<set>
using namespace std;

int main(){
	int t;
	cin >> t;
	for(int i = 0;i < t;i++){
		int k;
		cin >> k;
		int wa = k * (k + 1);
		if(wa % 4 != 0) cout << -1 << endl;
		else{
			wa /= 4;
			int hi = k;
			set<int> s;
			while(wa > 0){
				if(wa <= hi){
					s.insert(wa);
					break;
				}
				else{
					s.insert(hi);
					wa -= hi;
					hi--;
				}
			}
				for(int j = 1;j <= k;j++){
				if(s.find(j) != s.end()) cout << 1;
				else cout << 0;
			}
			cout << endl;
		}
	}
}
0