結果

問題 No.2608 Divide into two
ユーザー daiotadaiota
提出日時 2024-01-19 22:44:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 620 bytes
コンパイル時間 1,575 ms
コンパイル使用メモリ 167,912 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-19 22:45:05
合計ジャッジ時間 2,161 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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;

typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)


int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	 ll i,j,k;

	int T;
	cin >> T;

	while(T--){

		int N;
		cin >> N;

		if((N*(N+1)/2)%2==1){
			cout << -1 << endl;
			continue;
		}

		int s=N*(N+1)/4;

		string x(N,'0');

		int a=0,p=-1;
		for(i=N;i>=1;i--){
			if(a+i<=s){
				a+=i;
				x[i-1]='1';
			}
			else{
				p=i;
				break;
			}
		}

		for(i=p;i>=1;i--){
			if(a+i==s){
				x[i-1]='1';
				break;
			}
		}


		cout << x << endl;



	}



	return 0;

}
0