新人求助,平衡树那道题,本地AC提交RE

P3369 【模板】普通平衡树

这么冷吗?
by zhy137036 @ 2019-09-08 18:12:40


@[zhy123456](/space/show?uid=178294) 给你个datamaker自己对拍吧 ```cpp #include <ctime> #include <cstdlib> #include <iostream> #include <map> #include <set> using namespace std; set<int> s; int n = 15; int main(void) { int maxv = -1, minv = 0x7fffffff; srand(time(0)); cout << n << endl; while (n--) { if (!s.empty()) { int rv; if (s.size() >= 3) rv = rand() % 15; else rv = rand() % 10; if (rv < 3) { //erase cout << '2' << ' '; { auto i = s.begin(); int e = rand() % s.size(); for (; e; --e, ++i); cout << *i << endl; s.erase(*i); } } else if (rv < 5) { //insert cout << '1' << ' '; int v = rand() % 1000 + 1; if (v > maxv) maxv = v; if (v < minv) minv = v; s.insert(v); cout << v << endl; } else if (rv < 8) { //get_rank cout << '3' << ' '; { auto i = s.begin(); int e = rand() % s.size(); for (; e; --e, ++i); cout << *i << endl; } } else if (rv < 9) { //get_val cout << '4' << ' '; cout << rand() % s.size() + 1 << endl; } else if (rv < 12) { //get_pre if (maxv - minv + 1 <= 1) { ++n; continue;} cout << '5' << ' '; cout << (rand() % (maxv - minv + 1) + minv + 1) << endl; } else { //get_next if (maxv - minv + 1 <= 1) { ++n; continue;} cout << '6' << ' '; cout << (rand() % (maxv - minv + 1) + minv - 1) << endl; } } else { cout << '1' << ' '; int v = rand() % 1000 + 1; if (v > maxv) maxv = v; if (v < minv) minv = v; s.insert(v); cout << v << endl; } } return 0; } ```
by encore @ 2019-09-08 18:17:27


@[encore](/space/show?uid=113385) 我不会写生成随机数据的程序,能提供一个吗?~~不要脸ing~~
by zhy137036 @ 2019-09-08 18:23:26


@[zhy123456](/space/show?uid=178294) 就是上面那个啊
by encore @ 2019-09-08 18:24:00


@[zhy123456](/space/show?uid=178294) 那个是我以前做这道题时对拍用的,能生成一些小数据
by encore @ 2019-09-08 18:25:10


~~眼瞎~~
by zhy137036 @ 2019-09-08 18:26:38


|