luogu-dev / cyaron

CYaRon: Yet Another Random Olympic-iNformatics test data generator
GNU Lesser General Public License v3.0
1.37k stars 167 forks source link

Vector最大能生成长度为多少的不重复序列? #54

Open schrodingercatss opened 5 years ago

schrodingercatss commented 5 years ago

我想生成一个1e5的不重复数列,但是提示数据太大,Vector能生成的最大数量是多少呢?

StevenJinyanCheng commented 5 days ago
>>> import cyaron as cy
>>> l = cy.Vector.random(100000,)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\_____\AppData\Roaming\Python\Python311\site-packages\cyaron\vector.py", line 53, in random
    raise Exception("1st param is so large that CYaRon can not generate unique vectors")
Exception: 1st param is so large that CYaRon can not generate unique vectors
>>> l = cy.Vector.random(100000, [10])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\_____\AppData\Roaming\Python\Python311\site-packages\cyaron\vector.py", line 53, in random
    raise Exception("1st param is so large that CYaRon can not generate unique vectors")
Exception: 1st param is so large that CYaRon can not generate unique vectors
>>> l = cy.Vector.random(100000, [100000])
>>> len(l)
100000
>>> big_l = cy.Vector.random(1000000, [1000000])
>>> big_l = cy.Vector.random(1000000, [100000000])
>>>

要生成不重复的整数数据,最大值+1 一定要大于等于个数 例子:

cy.Vector.random(100, [99]) # 可以
cy.Vector.random(100, [1234567]) # 可以
cy.Vector.random(100, [10]) # 不行,10+1=11<100
cy.Vector.random(100, [123, 10, 1234]) # 可以,因为123+1=124>100,后面不重要
cy.Vector.random(1_000_000, [1_000_000_000]) # 可以

cyaron/cyaron/vector.py 第69-72行

        if mode == VectorRandomMode.unique and num > vector_space:
            raise ValueError(
                "1st param is so large that CYaRon can not generate unique vectors"
            )