結果
| 問題 |
No.2608 Divide into two
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-19 23:31:35 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 1,000 ms |
| コード長 | 1,119 bytes |
| コンパイル時間 | 2,680 ms |
| コンパイル使用メモリ | 249,624 KB |
| 実行使用メモリ | 7,040 KB |
| 最終ジャッジ日時 | 2024-09-28 05:07:58 |
| 合計ジャッジ時間 | 3,100 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N = 100;
vector<vector<int>> dp(N+1,vector<int>(N*N,-1));
dp[0][0] = 0;
for (int i = 1; i <= N; i++){
for (int j = 0; j <= N*N; j++){
if (dp[i-1][j] == -1) continue;
dp[i][j] = dp[i-1][j];
if (j+i > N*N) continue;
dp[i][j+i] = j;
}
}
int t;
cin >> t;
for (int i = 0; i < t; i++){
int n;
cin >> n;
int sum = n*(n+1)/2;
if (sum & 1 ) {
cout << -1 << endl;
continue;
}
int half = sum / 2;
if (dp[n][half] == -1){
cout << -1 << endl;
continue;
}
vector<int> ans(n);
int now = half;
for (int j = n;j > 0;j--){
int nex = dp[j][now];
if (nex == now) continue;
ans[now-nex-1] = 1;
now = nex;
}
for (auto a : ans){
cout << a;
}
cout << endl;
}
return 0;
}