結果

問題 No.2608 Divide into two
ユーザー Ywestbuilderk
提出日時 2024-01-22 19:00:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 506 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 75,116 KB
最終ジャッジ日時 2025-02-18 22:07:22
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 2
権限があれば一括ダウンロードができます

ソースコード

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