結果

問題 No.2608 Divide into two
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-01-20 12:02:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 704 bytes
コンパイル時間 2,831 ms
コンパイル使用メモリ 201,648 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-20 12:02:23
合計ジャッジ時間 3,134 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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;
void fast_io() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

int main() {
    fast_io();
    int t;
    cin >> t;
    for (; t--;) {
        int n;
        cin >> n;
        if (n % 4 == 0) {
            string ans(n, '0');
            for (int i = 0; i < n / 4; i++) {
                ans[i] = ans[n - i - 1] = '1';
            }
            cout << ans << "\n";
        } else if (n % 4 == 3) {
            string ans(n, '0');
            for (int i = 0; i < (n + 1) / 4; i++) {
                ans[i] = ans[n - i - 2] = '1';
            }
            cout << ans << "\n";
        } else {
            cout << "-1\n";
        }
    }
}
0