結果

問題 No.701 ひとりしりとり
コンテスト
ユーザー mamekin
提出日時 2018-06-15 22:44:01
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,782 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 711 ms
コンパイル使用メモリ 106,176 KB
最終ジャッジ日時 2026-03-20 18:31:15
合計ジャッジ時間 1,180 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:30:5: error: 'uint32_t' does not name a type
   30 |     uint32_t x, y, z, w;
      |     ^~~~~~~~
main.cpp:25:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
   24 | #include <iterator>
  +++ |+#include <cstdint>
   25 | using namespace std;
main.cpp:32:22: error: expected ')' before 'seed'
   32 |     Xorshift(uint32_t seed=88675123, int32_t loop=50){
      |             ~        ^~~~~
      |                      )
main.cpp:41:5: error: 'uint32_t' does not name a type
   41 |     uint32_t operator()(){
      |     ^~~~~~~~
main.cpp:41:5: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
main.cpp:46:5: error: 'uint32_t' does not name a type
   46 |     uint32_t operator()(uint32_t size){
      |     ^~~~~~~~
main.cpp:46:5: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
main.cpp:49:5: error: 'uint64_t' does not name a type
   49 |     uint64_t get64(){
      |     ^~~~~~~~
main.cpp:49:5: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
main.cpp:54:5: error: 'uint64_t' does not name a type
   54 |     uint64_t get64(uint64_t size){
      |     ^~~~~~~~
main.cpp:54:5: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
main.cpp: In member function 'void Xorshift::shuffle(std::vector<_Tp>&)':
main.cpp:59:9: error: 'uint32_t' was not declared in this scope [-Wtemplate-body]
   59 |         uint32_t n = v.size();
      |         ^~~~~~~~
main.cpp:59:9: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
main.cpp:60:22: error: expected ';' before 'i' [-Wtemplate-body]
   60 |         for(uint32_t i=0; i<n-1; ++i){
      |                      ^
main.cpp:60:27: error: 'i' was not declared in this scope [-Wtemplate-body]
  

ソースコード

diff #
raw source code

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class Xorshift
{
private:
    uint32_t x, y, z, w;
public:
    Xorshift(uint32_t seed=88675123, int32_t loop=50){
        x = 123456789;
        y = 362436069;
        z = 521288629;
        w = seed;
        while(--loop >= 0){
            (*this)();
        }
    }
    uint32_t operator()(){
        uint32_t t=(x^(x<<11));
        x=y; y=z; z=w;
        return w=(w^(w>>19))^(t^(t>>8));
    }
    uint32_t operator()(uint32_t size){
        return (*this)() % size;
    }
    uint64_t get64(){
        uint64_t a = (*this)();
        uint64_t b = (*this)();
        return (a << 32) | b;
    }
    uint64_t get64(uint64_t size){
        return get64() % size;
    }
    template <class T>
    void shuffle(vector<T>& v){
        uint32_t n = v.size();
        for(uint32_t i=0; i<n-1; ++i){
            uint32_t j = (*this)(n-i) + i;
            swap(v[i], v[j]);
        }
    }
};
Xorshift xorshift(time(NULL));

const int LEN = 20;

int main()
{
    int n;
    cin >> n;

    char prev = 'a';
    for(int i=0; i<n; ++i){
        string s(LEN, ' ');
        s[0] = prev;
        for(int j=1; j<LEN; ++j)
            s[j] = 'a' + xorshift(26);
        while((i == n - 1) ^ (s[LEN-1] == 'n'))
            s[LEN-1] = 'a' + xorshift(26);
        cout << s << endl;
        prev = s[LEN-1];
    }

    return 0;
}
0