結果

問題 No.2608 Divide into two
ユーザー suminoeno7suminoeno7
提出日時 2024-01-19 21:33:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 613 bytes
コンパイル時間 1,583 ms
コンパイル使用メモリ 168,424 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-19 21:33:08
合計ジャッジ時間 2,009 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 3 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    for (int j = 0; j < t; j++) {
        int n;
        cin >> n;
        if ((n * (n + 1) / 2 % 2) == 1) cout << -1 << endl;
        else {
            int x = (n + 1) * n / 4;
            vector<int> res(n + 1, 0);
            for (int i = n; i >= 1; i--) {
                if (x >= i) {
                    res[i]++;
                    x -= i;
                }
            }
            for (int i = 1; i <= n; i++) {
                cout << res[i];
                if (i == n) cout << endl;
            }
        }
    }
}
0