QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#687009#9231. Random NumberswangjunruiWA 188ms5760kbC++14761b2024-10-29 16:45:212024-10-29 16:45:22

Judging History

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

  • [2024-10-29 16:45:22]
  • 评测
  • 测评结果:WA
  • 用时:188ms
  • 内存:5760kb
  • [2024-10-29 16:45:21]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int N = 2e5 + 5;
constexpr int B = 500;
int n, a[N];
ll sum[N];
inline void work()
{
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
		sum[i] = sum[i - 1] + a[i];
	}
	int k = n / 2;
	int res = 0;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= min(B, max(k - B, 1) - 1); ++j)
			if (sum[i] - sum[i - j] == (ll)j * j)
				++res;
		for (int j = max(k - B, 1); j <= min(k + B, i); ++j)
			if (sum[i] - sum[i - j] == (ll)j * j)
				++res;
	}
	cout << res << '\n';
}
signed main()
{
//	freopen("project.in", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int T;
	cin >> T;
	while (T--)
		work();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5628kb

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: 188ms
memory: 5760kb

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:

2
2
2
3
1
4
2
2
2
1
3
2
3
4
2
3
1
1
2
3
2
2
2
2
1
2
1
1
4
3
1
1

result:

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