QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#687039 | #9231. Random Numbers | wangjunrui | WA | 188ms | 3720kb | C++14 | 842b | 2024-10-29 16:52:22 | 2024-10-29 16:52:22 |
Judging History
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];
bool vis[N];
inline void work(int T)
{
cin >> n;
if (T == 30)
cout << n << '\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(T);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
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: 3720kb
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 3167 3 2 3 1 4 3 2 2 1 4 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: '3167'