結果

問題 No.701 ひとりしりとり
ユーザー outlineoutline
提出日時 2021-01-06 17:29:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 366 ms / 2,000 ms
コード長 1,785 bytes
コンパイル時間 1,679 ms
コンパイル使用メモリ 138,864 KB
実行使用メモリ 167,280 KB
最終ジャッジ日時 2024-04-24 18:01:27
合計ジャッジ時間 7,186 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 362 ms
167,024 KB
testcase_01 AC 360 ms
167,156 KB
testcase_02 AC 354 ms
167,280 KB
testcase_03 AC 358 ms
166,992 KB
testcase_04 AC 358 ms
167,156 KB
testcase_05 AC 361 ms
167,152 KB
testcase_06 AC 360 ms
167,152 KB
testcase_07 AC 360 ms
167,160 KB
testcase_08 AC 366 ms
167,084 KB
testcase_09 AC 363 ms
167,156 KB
testcase_10 AC 361 ms
167,156 KB
testcase_11 AC 365 ms
167,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    vector<string> aa, ab, ba, bb;
    for(int mask = 0; mask < 1 << 20; ++mask){
        string s = "";
        for(int i = 0; i < 20; ++i){
            s += (mask >> i & 1) + 'a';
        }
        if(s[0] == 'a'){
            if(s[19] == 'a')    aa.emplace_back(s);
            else    ab.emplace_back(s);
        }
        else{
            if(s[19] == 'a')    ba.emplace_back(s);
            else    bb.emplace_back(s);
        }
    }
    vector<string> ans = bb;
    ans.emplace_back(ba[0]);
    for(int i = 0; i < (int)ab.size(); ++i){
        ans.emplace_back(ba[i]);
        ans.emplace_back(ab[i]);
    }
    copy(aa.begin(), aa.end(), back_inserter(ans));
    ans[n - 1][19] = 'n';
    for(int i = 0; i < n; ++i)  cout << ans[i] << '\n';

    return 0;
}
0