Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vector.random在生成n很大的数组时,生成的数量不够 #111

Open
GEJXD opened this issue Oct 13, 2023 · 2 comments
Open

Vector.random在生成n很大的数组时,生成的数量不够 #111

GEJXD opened this issue Oct 13, 2023 · 2 comments

Comments

@GEJXD
Copy link

GEJXD commented Oct 13, 2023

我写了一个这样的数据生成器:

from cyaron import *

test_data = IO(file_prefix="small", data_id=1)

n = randint(1, 4000)
test_data.input_writeln(n)

a = Vector.random(n, [(0, 1000)])
test_data.input_writeln(a)      
    
b = Vector.random(n, [(0, 1000)])
test_data.input_writeln(b)    
    
k = randint(1, 1000000)
test_data.input_writeln(k)

test_data.output_gen("./std")

然后把生成出来的数据文件用main.cpp(不是std)读取:

#include<bits/stdc++.h>

using i64 = long long;

void solve(){
	int n;
	std::cin >> n;
	std::cout << "n = " << n << '\n';

	i64 suma = 0;
	std::vector<int> a(n + 1);
	for (int i = 1;i <= n;i ++) {
		std::cin >> a[i];
		suma += a[i];
	}
	std::cout << "A: " << '\n';
	for (int i = 1;i <= n;i ++) {
		std::cout << a[i] << " \n"[i == n];
	}

	i64 sumb = 0;
	std::vector<int> b(n + 1);
	for (int i = 1;i <= n;i ++) {
		std::cin >> b[i];
		sumb += b[i];
	}
	std::cout << "B: " << '\n';
	for (int i = 1;i <= n;i ++) {
		std::cout << b[i] << " \n"[i == n];
	}

    int k;
    std::cin >> k;
	std::cout << "k = " << k << '\n';
}

int main(){
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);

    int tt = 1;
    //cin >> tt;
    while(tt --) solve();

    fclose(stdin);
    fclose(stdout);
    return 0;
}

但是他的输出是这个样子的:
image

其中的最后一个数字非0数字98223刚好是用cyaron生成的k值,所以我推测是Vector.random生成的数字数量不够,导致文件读入到了EOF,于是后面的数据都读成了0。
image

经过测试,n < 1000的规模生成的vector是没问题的,在大于1000左右的时候就会出现这种情况

@prayerhgq
Copy link

是的, 这个vector有问题。

@Mr-Python-in-China
Copy link

see: #109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants