提供 hack 数据生成器
查看原帖
提供 hack 数据生成器
574745
littlesnake楼主2024/6/1 14:54
# include <bits/stdc++.h>

using namespace std;

int n, a, m, l, r;

int main () {

	srand (time (0));
	n = 100000;
	cout << n << "\n";
	for (int i = 1; i <= n; i ++) {
		a = rand ();
		cout << a << " ";
	}
	cout << "\n";
	m = 100000;
	cout << m << "\n";
	for (int i = 1; i <= m; i ++) {
		l = 1, r = n;
		cout << l << " " << r << "\n"; 
	}

	return 0;

}


极限数据,足以卡掉加上 ios 优化的暴力,这里也跟大家说一声,卡常无效,杜绝卡常,多去学习正解。

卡掉了诸如这样的代码:

#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    long long n,m,a[100001],x,y,sum;
    cin>>n;for(int i=1;i<=n;i++)cin>>a[i];cin>>m; 
    for(int i=1;i<=m;i++){
        cin>>x>>y;sum=0;
        for(int j=x;j<=y;j++)sum+=a[j];
        cout<<sum<<'\n';
    }
    return 0;
}

因为数据可能没满,所以造成了卡过。

2024/6/1 14:54
加载中...