| Task: | Array |
| Sender: | lazycoder |
| Submission time: | 2015-09-30 18:12:34 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | RUNTIME ERROR | 0.15 s | details |
| #2 | RUNTIME ERROR | 0.13 s | details |
| #3 | RUNTIME ERROR | 0.15 s | details |
| #4 | RUNTIME ERROR | 0.14 s | details |
| #5 | RUNTIME ERROR | 0.13 s | details |
| #6 | RUNTIME ERROR | 0.15 s | details |
| #7 | RUNTIME ERROR | 0.15 s | details |
| #8 | RUNTIME ERROR | 0.16 s | details |
| #9 | RUNTIME ERROR | 0.15 s | details |
| #10 | RUNTIME ERROR | 0.15 s | details |
| #11 | RUNTIME ERROR | 0.15 s | details |
| #12 | RUNTIME ERROR | 0.15 s | details |
| #13 | RUNTIME ERROR | 0.15 s | details |
| #14 | RUNTIME ERROR | 0.15 s | details |
| #15 | RUNTIME ERROR | 0.17 s | details |
| #16 | RUNTIME ERROR | 0.17 s | details |
| #17 | RUNTIME ERROR | 0.15 s | details |
| #18 | RUNTIME ERROR | 0.15 s | details |
| #19 | RUNTIME ERROR | 0.16 s | details |
| #20 | RUNTIME ERROR | 0.16 s | details |
| #21 | RUNTIME ERROR | 0.15 s | details |
Compiler report
input/code.cpp: In function 'int main(int, char**)':
input/code.cpp:34:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < segTree.size(); j++)
^Code
#include <cstdlib>
#include<iostream>
#include<valarray>
#include <cmath>
#include<algorithm>
using namespace std;
std::valarray<int> input(1);
std::vector<int> segTree(1);
void constructTree(int low, int high, int pos) {
if (high == low) {
segTree[pos] = input[low];
return;
}
int mid = (low + high) / 2;
constructTree(low, mid, 2 * pos + 1);
constructTree(mid + 1, high, 2 * pos + 2);
segTree[pos] = segTree[2 * pos + 1] + segTree[2 * pos + 2];
}
int main(int argc, char** argv) {
cin. sync_with_stdio(false);
int N, x, cnt = 0;
cin>>N;
cin>>x;
input.resize(N);
int idx = N % 2 + N / 2;
segTree.resize(2 * pow(2, idx) - 1);
for (int i = 0; i < N; i++) {
cin >> input[i];
}
constructTree(0, N - 1, 0);
for (int j = 0; j < segTree.size(); j++)
cout << segTree[j] << endl;
cout.flush();
cnt = count(segTree.begin(), segTree.end(), x);
cout <<cnt << endl;
cout.flush();
return 0;
}
Test details
Test 1
Verdict: RUNTIME ERROR
| input |
|---|
| 89384 -6 -1 9 -2 0 0 -1 5 0 -8 9 10 -6 ... |
| correct output |
|---|
| 2029635 |
| user output |
|---|
| (empty) |
Test 2
Verdict: RUNTIME ERROR
| input |
|---|
| 32688 -4 6 0 9 -10 -2 -2 -1 5 -5 -6 9 8... |
| correct output |
|---|
| 321307 |
| user output |
|---|
| 0 |
Error:
*** Error in `input/code': free(): invalid next size (fast): 0x0000000000bb6030 ***
Test 3
Verdict: RUNTIME ERROR
| input |
|---|
| 11023 2 5 0 -1 9 -10 3 10 -10 1 -3 -8 ... |
| correct output |
|---|
| 146015 |
| user output |
|---|
| 0 |
Error:
*** Error in `input/code': free(): invalid next size (fast): 0x0000000001017030 ***
Test 4
Verdict: RUNTIME ERROR
| input |
|---|
| 36884 -7 6 8 2 -4 1 7 1 -7 5 3 1 -6 1 -... |
| correct output |
|---|
| 471565 |
| user output |
|---|
| (empty) |
Test 5
Verdict: RUNTIME ERROR
| input |
|---|
| 2875 -6 -4 1 -6 -10 -2 -5 9 0 -2 9 -3 ... |
| correct output |
|---|
| 9343 |
| user output |
|---|
| 0 |
Error:
*** Error in `input/code': free(): invalid next size (fast): 0x0000000000ccc030 ***
Test 6
Verdict: RUNTIME ERROR
| input |
|---|
| 52346 -111 973 629 570 312 541 -117 332 7... |
| correct output |
|---|
| 8791 |
| user output |
|---|
| (empty) |
Test 7
Verdict: RUNTIME ERROR
| input |
|---|
| 55283 298 593 -881 937 901 -91 -622 632 ... |
| correct output |
|---|
| 7351 |
| user output |
|---|
| (empty) |
Test 8
Verdict: RUNTIME ERROR
| input |
|---|
| 93592 -589 951 -193 -855 -692 926 -602 -6... |
| correct output |
|---|
| 26431 |
| user output |
|---|
| (empty) |
Test 9
Verdict: RUNTIME ERROR
| input |
|---|
| 98149 942 -816 178 196 -503 654 -474 -64... |
| correct output |
|---|
| 37659 |
| user output |
|---|
| (empty) |
Test 10
Verdict: RUNTIME ERROR
| input |
|---|
| 79573 -346 -161 619 720 182 726 452 -63 -... |
| correct output |
|---|
| 19690 |
| user output |
|---|
| (empty) |
Test 11
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 -9229 -6207 -4894 -1224 8410 -2954 4... |
| correct output |
|---|
| 1969 |
| user output |
|---|
| (empty) |
Test 12
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 4655 134 4684 8364 -7381 -1874 3429... |
| correct output |
|---|
| 2353 |
| user output |
|---|
| (empty) |
Test 13
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 -5901 -4907 7494 7673 -3917 -3223 -7... |
| correct output |
|---|
| 2345 |
| user output |
|---|
| (empty) |
Test 14
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 -2507 -845 -6674 -3174 9309 -1411 53... |
| correct output |
|---|
| 2242 |
| user output |
|---|
| (empty) |
Test 15
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 -4850 -9232 -2843 5422 -5336 -2835 -... |
| correct output |
|---|
| 3753 |
| user output |
|---|
| (empty) |
Test 16
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 -745023 -561148 78606 440682 608892 -3... |
| correct output |
|---|
| 27 |
| user output |
|---|
| (empty) |
Test 17
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 987216 602043 416718 216813 720665 -6... |
| correct output |
|---|
| 41 |
| user output |
|---|
| (empty) |
Test 18
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 -140762 -813926 -641015 5926 -87604 -8... |
| correct output |
|---|
| 43 |
| user output |
|---|
| (empty) |
Test 19
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 -828680 -53023 -23367 -91278 162438 82... |
| correct output |
|---|
| 27 |
| user output |
|---|
| (empty) |
Test 20
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 -731243595 -728764339 -159138563 36776806... |
| correct output |
|---|
| 0 |
| user output |
|---|
| (empty) |
Test 21
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... |
| correct output |
|---|
| 5000050000 |
| user output |
|---|
| (empty) |
