結果
問題 | No.2608 Divide into two |
ユーザー |
![]() |
提出日時 | 2024-01-19 21:37:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 722 bytes |
コンパイル時間 | 1,902 ms |
コンパイル使用メモリ | 194,400 KB |
最終ジャッジ日時 | 2025-02-18 20:47:36 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 2 |
ソースコード
#include <bits/stdc++.h> #ifdef LOCAL #include "./debug.cpp" #else #define debug(...) #define print_line #endif using namespace std; using ll = long long; int main() { int T; cin >> T; while (T--) { int N; cin >> N; int M = N * (N + 1) / 2; if (M % 2 == 1) { cout << -1 << endl; } else { M /= 2; int now = 0, sum = 0; vector<char> ans(N, '0'); while (sum + now + 1 <= M) { now++; sum += now; ans[now - 1] = '1'; } if (sum < M) { int d = M - sum; if (N - d <= now) { ans[N - d - 1] = '0'; ans[N - 1] = '1'; } else { ans[now - 1] = '0'; ans[now + d - 1] = '1'; } } for (int i = 0; i < N; i++) cout << ans[i]; cout << endl; } } }