Task: | Subarray Sums II |
Sender: | joaquimballester |
Submission time: | 2024-11-23 16:00:36 +0200 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.00 s | details |
#2 | WRONG ANSWER | 0.00 s | details |
#3 | WRONG ANSWER | 0.00 s | details |
#4 | WRONG ANSWER | 0.00 s | details |
#5 | WRONG ANSWER | 0.00 s | details |
#6 | WRONG ANSWER | 0.00 s | details |
#7 | WRONG ANSWER | 0.00 s | details |
#8 | WRONG ANSWER | 0.00 s | details |
#9 | WRONG ANSWER | 0.00 s | details |
#10 | WRONG ANSWER | 0.01 s | details |
#11 | WRONG ANSWER | 0.00 s | details |
#12 | WRONG ANSWER | 0.00 s | details |
#13 | WRONG ANSWER | 0.01 s | details |
#14 | WRONG ANSWER | 0.00 s | details |
#15 | WRONG ANSWER | 0.00 s | details |
#16 | WRONG ANSWER | 0.00 s | details |
#17 | WRONG ANSWER | 0.00 s | details |
#18 | WRONG ANSWER | 0.00 s | details |
#19 | WRONG ANSWER | 0.00 s | details |
#20 | WRONG ANSWER | 0.00 s | details |
#21 | WRONG ANSWER | 0.00 s | details |
#22 | WRONG ANSWER | 0.00 s | details |
#23 | WRONG ANSWER | 0.00 s | details |
#24 | WRONG ANSWER | 0.00 s | details |
#25 | WRONG ANSWER | 0.00 s | details |
#26 | WRONG ANSWER | 0.00 s | details |
#27 | WRONG ANSWER | 0.00 s | details |
#28 | WRONG ANSWER | 0.00 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:21:15: warning: unused variable 'N' [-Wunused-variable] 21 | long long N = 5, X = 3; | ^
Code
#include <iostream> #include <unordered_map> #include <vector> using namespace std; long long countSubarrays(vector<long long>& arr, long long X) { unordered_map<long long, long long> prefixCounts; prefixCounts[0] = 1; long long prefixSum = 0, count = 0; for (auto num : arr) { prefixSum += num; count += prefixCounts[prefixSum - X]; prefixCounts[prefixSum]++; } return count; } int main() { long long N = 5, X = 3; vector<long long> arr = {1, 1, 1, -1, 1}; cout << countSubarrays(arr, X) << endl; return 0; }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
100 50 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
51 |
user output |
---|
2 |
Test 2
Verdict: WRONG ANSWER
input |
---|
100 1000000000 1000000000 1000000000 10000000... |
correct output |
---|
100 |
user output |
---|
2 |
Test 3
Verdict: WRONG ANSWER
input |
---|
100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... |
correct output |
---|
5050 |
user output |
---|
2 |
Test 4
Verdict: WRONG ANSWER
input |
---|
100 4 2 1 -3 2 -7 7 -2 6 9 -4 10 -6 ... |
correct output |
---|
53 |
user output |
---|
2 |
Test 5
Verdict: WRONG ANSWER
input |
---|
200000 100000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
100001 |
user output |
---|
2 |
Test 6
Verdict: WRONG ANSWER
input |
---|
200000 1000000000 1000000000 1000000000 10000000... |
correct output |
---|
200000 |
user output |
---|
2 |
Test 7
Verdict: WRONG ANSWER
input |
---|
200000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... |
correct output |
---|
20000100000 |
user output |
---|
2 |
Test 8
Verdict: WRONG ANSWER
input |
---|
200000 39 44 -62 -3 23 11 -68 42 69 -22 ... |
correct output |
---|
903601 |
user output |
---|
2 |
Test 9
Verdict: WRONG ANSWER
input |
---|
131072 199999 199999 199999 199999 199999 19... |
correct output |
---|
131072 |
user output |
---|
2 |
Test 10
Verdict: WRONG ANSWER
input |
---|
131072 107897 107897 107897 107897 107897 10... |
correct output |
---|
131072 |
user output |
---|
2 |
Test 11
Verdict: WRONG ANSWER
input |
---|
131072 126271 126271 126271 126271 126271 12... |
correct output |
---|
131072 |
user output |
---|
2 |
Test 12
Verdict: WRONG ANSWER
input |
---|
200000 107897 107897 107897 107897 107897 10... |
correct output |
---|
199999 |
user output |
---|
2 |
Test 13
Verdict: WRONG ANSWER
input |
---|
200000 100000 1056323 1056323 1056323 105632... |
correct output |
---|
0 |
user output |
---|
2 |
Test 14
Verdict: WRONG ANSWER
input |
---|
200000 100000 2144977 2144977 2144977 214497... |
correct output |
---|
0 |
user output |
---|
2 |
Test 15
Verdict: WRONG ANSWER
input |
---|
200000 100000 65536 65536 65536 65536 65536 ... |
correct output |
---|
0 |
user output |
---|
2 |
Test 16
Verdict: WRONG ANSWER
input |
---|
5 0 0 0 0 0 0 |
correct output |
---|
15 |
user output |
---|
2 |
Test 17
Verdict: WRONG ANSWER
input |
---|
20 536870912 268435456 268435456 268435456 ... |
correct output |
---|
19 |
user output |
---|
2 |
Test 18
Verdict: WRONG ANSWER
input |
---|
131072 136607 136607 136607 136607 136607 13... |
correct output |
---|
131072 |
user output |
---|
2 |
Test 19
Verdict: WRONG ANSWER
input |
---|
200000 562841 562841 562841 562841 562841 56... |
correct output |
---|
200000 |
user output |
---|
2 |
Test 20
Verdict: WRONG ANSWER
input |
---|
107897 107897 107897 107897 107897 107897 10... |
correct output |
---|
107897 |
user output |
---|
2 |
Test 21
Verdict: WRONG ANSWER
input |
---|
200000 202409 101204 101205 101204 101205 10... |
correct output |
---|
199998 |
user output |
---|
2 |
Test 22
Verdict: WRONG ANSWER
input |
---|
200000 202409 138630 138631 138630 138631 13... |
correct output |
---|
0 |
user output |
---|
2 |
Test 23
Verdict: WRONG ANSWER
input |
---|
200000 10273 410857 410857 410857 410857 41... |
correct output |
---|
0 |
user output |
---|
2 |
Test 24
Verdict: WRONG ANSWER
input |
---|
5 2 1 -1 1 -1 2 |
correct output |
---|
3 |
user output |
---|
2 |
Test 25
Verdict: WRONG ANSWER
input |
---|
200000 1 1048577 -1048570 29 145 725 36... |
correct output |
---|
104671 |
user output |
---|
2 |
Test 26
Verdict: WRONG ANSWER
input |
---|
200000 1 1048577 -1048571 25 125 625 31... |
correct output |
---|
104859 |
user output |
---|
2 |
Test 27
Verdict: WRONG ANSWER
input |
---|
200000 0 5334500 -3502392 3421268 -2064... |
correct output |
---|
6341575890 |
user output |
---|
2 |
Test 28
Verdict: WRONG ANSWER
input |
---|
200000 0 172933 172933 172933 172933 17... |
correct output |
---|
0 |
user output |
---|
2 |