結果

問題 No.600 かい文回
ユーザー xuzijian629xuzijian629
提出日時 2018-09-14 14:41:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,418 bytes
コンパイル時間 1,021 ms
コンパイル使用メモリ 105,308 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-18 14:28:17
合計ジャッジ時間 5,058 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <chrono>
#include <random>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <cassert>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
using i128 = __int128_t;
constexpr i64 MOD = 1e9 + 7;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<i64, i64>;

int main() {
    int n;
    cin >> n;
    n--;
    deque<char> ans = {'a'};
    string b = "";
    while (n) {
        b += '0' + (n & 1);
        n >>= 1;
    }
    reverse(b.begin(), b.end());
    for (int i = 0; i < b.size(); i++) {
        if (b[i] == '1') {
            auto other = [](char a) {
                return a == 'a' ? 'b' : 'a';
            };
            ans.push_front(other(ans.front()));
            ans.push_back(other(ans.back()));
        }
        if (i != b.size() - 1) {
            ans.push_front(ans.front());
            ans.push_back(ans.back());
        }
    }
    for (int i = 0; i < ans.size() - 1; i++) {
        cout << ans[i];
    }
    cout << ans.back() << endl;
}
0