結果
| 問題 | No.701 ひとりしりとり | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-08-12 02:38:35 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 7 ms / 2,000 ms | 
| コード長 | 758 bytes | 
| コンパイル時間 | 509 ms | 
| コンパイル使用メモリ | 65,528 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-23 06:45:01 | 
| 合計ジャッジ時間 | 1,396 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 12 | 
ソースコード
#include <iostream>
#include <string>
using namespace std;
void next_string(string &s){
    if (s[3] < 'z'){
        ++s[3];
        return;
    }else{
        s[3] = 'a';
    }
    if (s[2] < 'z'){
        ++s[2];
        return ;
    }else{
        s[2] = 'a';
    }
    if (s[1] < 'z'){
        ++s[1];
        return ;
    }else{
        s[1] = 'a';
    }
    if (s[0] < 'z'){
        ++s[0];
        return ;
    }else{
        s[1] = 'a';
        cout << "overflow" << endl;
    }
    return;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s = "aaaa";
    for (int i = 1; i < n; ++i){
        cout << 'a' << s << 'a' << '\n';
        next_string(s);
    }
    cout << "an" << endl;
    return 0;
}
            
            
            
        