結果

問題 No.701 ひとりしりとり
ユーザー donkorin_donkorin_
提出日時 2018-09-11 14:43:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,509 bytes
コンパイル時間 1,498 ms
コンパイル使用メモリ 166,912 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-05 12:58:05
合計ジャッジ時間 3,742 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;

string random_string(size_t length)
{
    auto randchar = []() -> char {
        const char charset[] =
            "abcdefghijklmnopqrstuvwxyz";
        const size_t max_index = (sizeof(charset) - 1);
        return charset[rand() % max_index];
    };
    string str(length, 0);
    generate_n(str.begin(), length, randchar);
    return str;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    string t = "a"; 
    char begin = 'a', last = 'a';
    cout << t << endl;
    rep(i, 0, n-1) {
        t = random_string(i%18+2);
        if (last != t[0]) t[0] = last, begin = t[0];
        if (i == n-2) t[t.size()-1] = 'n';
        else last = t[t.size()-1];
        cout << t << endl;
    }
    return 0;
}
0