結果

問題 No.701 ひとりしりとり
ユーザー treeonetreeone
提出日時 2018-06-15 22:27:34
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,216 bytes
コンパイル時間 1,405 ms
コンパイル使用メモリ 155,544 KB
実行使用メモリ 21,020 KB
最終ジャッジ日時 2023-09-13 04:48:29
合計ジャッジ時間 3,562 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 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, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

unsigned ww;
unsigned xor128() {
    static unsigned x = 123456789, y = 362436069, z = 521288629/*, w = 88675123*/;
    unsigned t = (x ^ (x << 11));
    x = y; y = z; z = ww;
    return (ww = (ww ^ (ww >> 19)) ^ (t ^ (t >> 8)));
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<string> ans;
    set<string> st;
    rep(i, 0, n){
        string s = "";
        while(1){
            s = "";
            if(i != 0) s += ans[i - 1][ans[i - 1].size() - 1];
            while(s.size() < 20){
                s += 'a' + xor128() % 26;
            }
            if(i == n - 1) s[s.size() - 1] = 'n';
            if(!st.count(s)){
                st.insert(s);
                break;
            }
        }
        ans.push_back(s);
    }
    for(int ii = 0; ii < ans.size(); ii++){
        cout << ans[ii] << endl;
    }
}
0