QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#599956#9231. Random Numbersleafmaple#WA 148ms7756kbC++20833b2024-09-29 13:37:262024-09-29 13:37:26

Judging History

你现在查看的是最新测评结果

  • [2024-09-29 13:37:26]
  • 评测
  • 测评结果:WA
  • 用时:148ms
  • 内存:7756kb
  • [2024-09-29 13:37:26]
  • 提交

answer

#include <bits/stdc++.h>
#define xs(a) cout<<setiosflags(ios::fixed)<<setprecision(a);
#define endl '\n'
using namespace std;
using ll = long long;
const int N=1e6+5;
#define int long long
int a[N], pre[N];
void solve(){
	int n; cin >> n;
	for(int i=1; i<=n; i++) cin >> a[i], pre[i] = pre[i-1] + a[i];
	int res = 0;

	auto cal = [&](int len){
		int cnt = 0;
		for(int i=1; i+len-1<=n; i++){
			if(pre[i+len-1] - pre[i-1] == len*len)cnt++;
		}
		return cnt;
	};

	int lim = 0;
	// for(int i=1; i<=min(n, lim); i++) res += cal(i);
	// if(n <= lim){
	// 	cout << res << endl;
	// 	return ;
	// }
	for(int i=max(lim+1,n/2-1000); i<=min(n,n/2+1000); i++) res += cal(i);
	cout << res << endl;
}

signed main(){
	cin.tie(0)->sync_with_stdio(0);
	int T; T=1;
	cin >> T;
	while(T--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 5692kb

input:

2
3
2 1 3
5
3 4 2 5 1

output:

2
2

result:

ok 2 number(s): "2 2"

Test #2:

score: -100
Wrong Answer
time: 148ms
memory: 7756kb

input:

32
9811
3756 4960 5623 8471 9330 2388 7066 5434 4707 1711 2109 7274 9630 5057 6390 3252 2632 2291 4697 1923 6423 369 2430 2586 549 1344 1518 9170 268 1315 8808 4843 4603 532 2210 275 835 9059 8529 3449 1412 6071 6737 6944 788 8202 6684 6926 1729 7530 6506 9781 5523 5864 7067 9398 3446 2044 2578 2530...

output:

1
0
0
2
0
3
1
1
1
0
2
1
2
3
1
2
0
0
1
1
1
1
1
0
0
1
0
0
2
1
0
0

result:

wrong answer 1st numbers differ - expected: '2', found: '1'