随机化强强强

· · 题解

显然,随机一个长度 50000 的序列成功率很高,考虑随机化。

我取了 1000 个,然后随机取一个,这样子的错误概率比滚木低。而且你也卡不掉。

#include <bits/stdc++.h>
using namespace std;
string p[1005];
int main()
{
    string s = "UDLR";
    srand(time(0));
    int F = 1000;
    string A;
    while(F--)
    {
        int G = 50000;
        string ans;
        while(G--)
            ans += s[rand() % 4];
        p[F] = ans;
    }
    cout << p[rand() % F + 1];
}