Task: | Bittilista |
Sender: | ollpu |
Submission time: | 2016-07-29 14:12:59 +0300 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | RUNTIME ERROR | 0 |
#2 | RUNTIME ERROR | 0 |
#3 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | RUNTIME ERROR | 0.14 s | 1 | details |
#2 | RUNTIME ERROR | 0.14 s | 1 | details |
#3 | RUNTIME ERROR | 0.14 s | 1 | details |
#4 | RUNTIME ERROR | 0.13 s | 1 | details |
#5 | RUNTIME ERROR | 0.14 s | 1 | details |
#6 | RUNTIME ERROR | 0.15 s | 2 | details |
#7 | RUNTIME ERROR | 0.14 s | 2 | details |
#8 | RUNTIME ERROR | 0.15 s | 2 | details |
#9 | RUNTIME ERROR | 0.16 s | 2 | details |
#10 | RUNTIME ERROR | 0.14 s | 2 | details |
#11 | RUNTIME ERROR | 0.15 s | 3 | details |
#12 | RUNTIME ERROR | 0.14 s | 3 | details |
#13 | RUNTIME ERROR | 0.14 s | 3 | details |
#14 | RUNTIME ERROR | 0.15 s | 3 | details |
#15 | RUNTIME ERROR | 0.14 s | 3 | details |
Code
#include <iostream>using namespace std;struct node {node* left;node* right;int pr, size;unsigned long val, diff, sum;bool flip;node(unsigned long v) {left = nullptr;right = nullptr;size = 1;pr = rand();val = v;diff = 0;flip = 0;sum = 0;}};int size(node* s) {if (s == nullptr) return 0;return s->size;}unsigned long sum(node* s) {if (s == nullptr) return 0;return s->sum;}void lazy_pull(node* s) {if (s == nullptr) return;s->size = size(s->left) + size(s->right) + 1;s->sum = s->val + sum(s->left) + sum(s->right);}void lazy_push(node* s) {if (s == nullptr) return;if (s->flip) {swap(s->left, s->right);if (s->left != nullptr) s->left->flip = !s->left->flip;if (s->right != nullptr) s->right->flip = !s->right->flip;s->flip = false;}if (s->left != nullptr) s->left->diff += s->diff;if (s->right != nullptr) s->right->diff += s->diff;s->val += s->diff;s->diff = 0;}void join(node*& s, node* left, node* right) {lazy_push(left);lazy_push(right);if (left == nullptr) s = right;else if (right == nullptr) s = left;else {if (left->pr > right->pr) {join(left->right, left->right, right);s = left;} else {join(right->left, left, right->left);s = right;}}lazy_pull(s);}void split(node* s, node*& left, node*& right, int k) {if (s == nullptr) {left = nullptr;right = nullptr;return;}lazy_push(s);if (size(s->left) >= k) {split(s->left, left, s->left, k);right = s;} else {split(s->right, s->right, right, k - size(s->left) - 1);left = s;}lazy_pull(s);}void getindex(node* s, node*& result, int i) {lazy_push(s);if (size(s->left) == i) {result = s;} else if (size(s->left) > i) {getindex(s->left, result, i);} else {getindex(s->right, result, i-size(s->left)-1);}}int main() {ios_base::sync_with_stdio(0);cin.tie(0);int n, q;cin >> n >> q;node *tree = nullptr;for (int i = 0; i < n; ++i) {join(tree, tree, new node(0));}for (int qi = 0; qi < q; ++qi) {char c;int a, b;cin >> c >> a >> b;node *left, *middle, *right;split(tree, left, middle, a-1);split(middle, middle, right, b-a+1);if (c == 'S') {cout << sum(middle) << '\n';} else if (c == 'R') {middle->flip = !middle->flip;} else {unsigned long d;cin >> d;middle->diff += d;}join(tree, left, middle);join(tree, tree, right);}}
Test details
Test 1
Group: 1
Verdict: RUNTIME ERROR
input |
---|
10 54 |
correct output |
---|
0001101010 |
user output |
---|
(empty) |
Test 2
Group: 1
Verdict: RUNTIME ERROR
input |
---|
10 302 |
correct output |
---|
1001011011 |
user output |
---|
(empty) |
Test 3
Group: 1
Verdict: RUNTIME ERROR
input |
---|
10 241 |
correct output |
---|
0111100000 |
user output |
---|
(empty) |
Test 4
Group: 1
Verdict: RUNTIME ERROR
input |
---|
10 382 |
correct output |
---|
1011111011 |
user output |
---|
(empty) |
Test 5
Group: 1
Verdict: RUNTIME ERROR
input |
---|
10 138 |
correct output |
---|
0100010010 |
user output |
---|
(empty) |
Test 6
Group: 2
Verdict: RUNTIME ERROR
input |
---|
20 131002 |
correct output |
---|
00111111111101110010 |
user output |
---|
(empty) |
Test 7
Group: 2
Verdict: RUNTIME ERROR
input |
---|
20 441567 |
correct output |
---|
11010111100110111101 |
user output |
---|
(empty) |
Test 8
Group: 2
Verdict: RUNTIME ERROR
input |
---|
20 109770 |
correct output |
---|
00110101100110010010 |
user output |
---|
(empty) |
Test 9
Group: 2
Verdict: RUNTIME ERROR
input |
---|
20 327308 |
correct output |
---|
10011111110100010111 |
user output |
---|
(empty) |
Test 10
Group: 2
Verdict: RUNTIME ERROR
input |
---|
20 302918 |
correct output |
---|
10010011111010001011 |
user output |
---|
(empty) |
Test 11
Group: 3
Verdict: RUNTIME ERROR
input |
---|
50 216967103451763 |
correct output |
---|
011000101010101001001011100100... |
user output |
---|
(empty) |
Test 12
Group: 3
Verdict: RUNTIME ERROR
input |
---|
50 236618662270629 |
correct output |
---|
011010111001101000001001101001... |
user output |
---|
(empty) |
Test 13
Group: 3
Verdict: RUNTIME ERROR
input |
---|
50 426560943304480 |
correct output |
---|
110000011111101000111010110000... |
user output |
---|
(empty) |
Test 14
Group: 3
Verdict: RUNTIME ERROR
input |
---|
50 294553802415801 |
correct output |
---|
100001011111001010010011011000... |
user output |
---|
(empty) |
Test 15
Group: 3
Verdict: RUNTIME ERROR
input |
---|
50 502225394100883 |
correct output |
---|
111001000110001010111011000110... |
user output |
---|
(empty) |