結果

問題 No.701 ひとりしりとり
ユーザー treeonetreeone
提出日時 2018-06-15 22:30:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 275 ms / 2,000 ms
コード長 1,270 bytes
コンパイル時間 1,311 ms
コンパイル使用メモリ 155,848 KB
実行使用メモリ 20,288 KB
最終ジャッジ日時 2023-09-13 04:49:57
合計ジャッジ時間 2,718 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 24 ms
4,812 KB
testcase_11 AC 275 ms
20,288 KB
権限があれば一括ダウンロードができます

ソースコード

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';
            else if(s[s.size() - 1] == 'n') continue;
            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