problem_id
stringlengths
6
6
language
stringclasses
2 values
original_status
stringclasses
3 values
original_src
stringlengths
19
243k
changed_src
stringlengths
19
243k
change
stringclasses
3 values
i1
int64
0
8.44k
i2
int64
0
8.44k
j1
int64
0
8.44k
j2
int64
0
8.44k
error
stringclasses
270 values
stderr
stringlengths
0
226k
p02282
C++
Runtime Error
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int n, pos; vector<int> pre, in, post; void rec(int l, int r) { if (l >= r) return; int root = pre[pos++]; int m = distance(in.begin(), find(in.begin(), in.end(), root)); rec(1, m); rec(m + 1, r); post.pu...
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int n, pos; vector<int> pre, in, post; void rec(int l, int r) { if (l >= r) return; int root = pre[pos++]; int m = distance(in.begin(), find(in.begin(), in.end(), root)); rec(l, m); rec(m + 1, r); post.pu...
replace
14
15
14
15
-11
p02282
C++
Runtime Error
#include <iostream> using namespace std; #include <stdio.h> #include <stdlib.h> void to_post(int *A, int *B, int *C, int h) { int x = A[0]; C[h - 1] = x; if (h < 2) return; int m = 0; while (B[m] != x) m++; if (m > 0) to_post(A + 1, B, C, m); if (h - m - 1 > 0) to_post(A + m + 1, B + m + ...
#include <iostream> using namespace std; #include <stdio.h> #include <stdlib.h> void to_post(int *A, int *B, int *C, int h) { int x = A[0]; C[h - 1] = x; if (h < 2) return; int m = 0; while (B[m] != x) m++; if (m > 0) to_post(A + 1, B, C, m); if (h - m - 1 > 0) to_post(A + m + 1, B + m + ...
replace
35
36
35
36
-11
p02282
C++
Runtime Error
#include <algorithm> #include <iostream> #include <vector> class BinaryTree { private: static const int NIL = -1; struct Node { int parent, sibling, left, right, degree, depth, height; Node() { parent = sibling = left = right = depth = height = NIL; degree = 0; } }; std::vector<Node> T;...
#include <algorithm> #include <iostream> #include <vector> class BinaryTree { private: static const int NIL = -1; struct Node { int parent, sibling, left, right, degree, depth, height; Node() { parent = sibling = left = right = depth = height = NIL; degree = 0; } }; std::vector<Node> T;...
replace
23
24
23
27
0
p02282
C++
Runtime Error
/*! if g++ -g alds_1_7_d.cpp -o alds_1_7_d.out; then ./alds_1_7_d.out < * alds_1_7_d.test; fi */ #include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <iterator> #include <map> #include <nu...
/*! if g++ -g alds_1_7_d.cpp -o alds_1_7_d.out; then ./alds_1_7_d.out < * alds_1_7_d.test; fi */ #include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <iterator> #include <map> #include <nu...
replace
79
81
79
81
0
p02282
C++
Runtime Error
#include <cstdlib> #include <iostream> #include <list> const int MAX_N = 25; const int SINGLE_NODE = 1; const int NONE = -1; struct Node { int parent; int left; int right; bool visited; }; int reconstruct(std::list<int> *preorderNodes, std::list<int> *inorderNodes, int parent, struct Node *no...
#include <cstdlib> #include <iostream> #include <list> const int MAX_N = 41; const int SINGLE_NODE = 1; const int NONE = -1; struct Node { int parent; int left; int right; bool visited; }; int reconstruct(std::list<int> *preorderNodes, std::list<int> *inorderNodes, int parent, struct Node *no...
replace
4
5
4
5
0
p02282
C++
Runtime Error
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int n, pos; vector<int> pre, in, post; void rec(int l, int r) { if (l >= r) return; int root = pre[pos++]; int m = distance(in.begin(), find(in.begin(), in.end(), root)); rec(l, m); rec(m + l, r); post.pu...
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int n, pos; vector<int> pre, in, post; void rec(int l, int r) { if (l >= r) return; int root = pre[pos++]; int m = distance(in.begin(), find(in.begin(), in.end(), root)); rec(l, m); rec(m + 1, r); post.pu...
replace
15
16
15
16
-11
p02282
C++
Runtime Error
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <cmath> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) using namespace std; typedef long ...
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <cmath> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) using namespace std; typedef long ...
replace
16
17
16
17
0
p02282
C++
Runtime Error
#include <algorithm> #include <array> #include <cstdio> #include <iostream> #include <list> #include <numeric> #include <queue> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <map> #include <math.h> #define SENTINEL 1000000001 #define min...
#include <algorithm> #include <array> #include <cstdio> #include <iostream> #include <list> #include <numeric> #include <queue> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <map> #include <math.h> #define SENTINEL 1000000001 #define min...
replace
186
187
186
187
0
p02283
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; struct node { int lc; int rc; int key; void init(int a) { lc = rc = -1; key = a; } }; #define bstN 200000 struct bst { int size; node t[bstN]; void init() { size = 0; } void insert(int v) { int i = 0; while (i < size) { int &chil...
#include <bits/stdc++.h> using namespace std; struct node { int lc; int rc; int key; void init(int a) { lc = rc = -1; key = a; } }; #define bstN 600000 struct bst { int size; node t[bstN]; void init() { size = 0; } void insert(int v) { int i = 0; while (i < size) { int &chil...
replace
13
14
13
14
0
p02283
C++
Time Limit Exceeded
#include <iostream> #include <queue> #include <utility> #include <vector> using namespace std; class node { public: int parent, children[2], sib, val; node() { parent = -1; children[0] = -1; children[1] = -1; sib = -1; val = -1; } int deg() { int c = 0; for (int i = 0; i < 2; i++) ...
#include <iostream> #include <queue> #include <utility> #include <vector> using namespace std; class node { public: int parent, children[2], sib, val; node() { parent = -1; children[0] = -1; children[1] = -1; sib = -1; val = -1; } int deg() { int c = 0; for (int i = 0; i < 2; i++) ...
replace
35
36
35
36
TLE
p02283
C++
Runtime Error
#include <cstdio> #include <iostream> #include <string> using namespace std; struct Node { int key; Node *left; Node *right; Node() { left = right = NULL; } }; class Tree { Node *root; public: void insert(Node *n) { Node *y = NULL; Node *x = root; while (x != NULL) { y = x; if (n...
#include <cstdio> #include <iostream> #include <string> using namespace std; struct Node { int key; Node *left; Node *right; Node() { left = right = NULL; } }; class Tree { Node *root = NULL; public: void insert(Node *n) { Node *y = NULL; Node *x = root; while (x != NULL) { y = x; ...
replace
14
15
14
15
-11
p02283
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; struct Node { int key; Node *right, *left, *parent; }; Node *root, *NIL; void insert(int k) { Node *y = NIL; Node *x = root; Node *z; z = (Node *)malloc(sizeof(Node)); z->key = k; z->left = NIL; z->right = NIL; while (x != NIL) { y = x; if (...
#include <bits/stdc++.h> using namespace std; struct Node { int key; Node *right, *left, *parent; }; Node *root, *NIL; void insert(int k) { Node *y = NIL; Node *x = root; Node *z; z = (Node *)malloc(sizeof(Node)); z->key = k; z->left = NIL; z->right = NIL; while (x != NIL) { y = x; if (...
replace
62
63
62
63
-11
p02283
C++
Memory Limit Exceeded
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; #define N 4500000 #define NIL -1 int key[N]; int parent[N]; int leftc[N]; int rightc[N]; int root = NIL; void insert(int z) { int x, y; y = NIL; x = root; while (x != NIL) { y = x; if (key[z] < key[x]) ...
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; #define N 4000000 #define NIL -1 int key[N]; int parent[N]; int leftc[N]; int rightc[N]; int root = NIL; void insert(int z) { int x, y; y = NIL; x = root; while (x != NIL) { y = x; if (key[z] < key[x]) ...
replace
6
7
6
7
MLE
p02283
C++
Time Limit Exceeded
#include <iostream> #include <stdlib.h> #include <string> #include <vector> using namespace std; class Node { public: Node *l, *r; int key; }; void insert(Node **root, int key) { Node **cur = root, *node = new Node; node->l = NULL; node->r = NULL; node->key = key; while (NULL != *cur) { if (node->ke...
#include <iostream> #include <stdlib.h> #include <string> #include <vector> using namespace std; class Node { public: Node *l, *r; int key; }; void insert(Node **root, int key) { Node **cur = root, *node = new Node; node->l = NULL; node->r = NULL; node->key = key; while (NULL != *cur) { if (node->ke...
delete
41
42
41
41
TLE
p02283
C++
Runtime Error
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; struct Node { int key; Node *right, *left, *parent; }; Node *root, *NIL; void insert(int k) { Node *y = NIL; Node *x = root; Node *z; z = (Node *)malloc(sizeof(Node)); z->key = k; z->left = NIL; z->righ...
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; struct Node { int key; Node *right, *left, *parent; }; Node *root, *NIL; void insert(int k) { Node *y = NIL; Node *x = root; Node *z; z = (Node *)malloc(sizeof(Node)); z->key = k; z->left = NIL; z->righ...
replace
32
33
32
33
-11
p02283
C++
Runtime Error
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; struct Node { int key; Node *right, *left, *parent; }; Node *root, *NIL; void insert(int k) { Node *y = NIL; Node *x = root; Node *z; z = (Node *)malloc(sizeof(Node)); z->key = k; z->left = NIL; z->righ...
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; struct Node { int key; Node *right, *left, *parent; }; Node *root, *NIL; void insert(int k) { Node *y = NIL; Node *x = root; Node *z; z = (Node *)malloc(sizeof(Node)); z->key = k; z->left = NIL; z->righ...
replace
45
46
45
46
-11
p02283
C++
Runtime Error
#include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <string> using namespace std; #define N 100000 int key[N]; int rt[N]; int lt[N]; int parent[N]; int np = 0; int root = -1; void insert(int k) { int y = -1; int x = root; while (x != -1) { y = x; if (k < key[x]) { x ...
#include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <string> using namespace std; #define N 500000 int key[N]; int rt[N]; int lt[N]; int parent[N]; int np = 0; int root = -1; void insert(int k) { int y = -1; int x = root; while (x != -1) { y = x; if (k < key[x]) { x ...
replace
7
8
7
8
0
p02283
C++
Runtime Error
/* * ALDS1_8_A.cpp * * Created on: May 2, 2018 * Author: 13743 */ #include <cstdio> #include <cstdlib> struct Node { int key; Node *pa, *lc, *rc; }; Node *root = NULL; void insert(int k) { Node *y = NULL; Node *x = root; Node *z = new Node; while (x != NULL) { y = x; if (k < y->key) ...
/* * ALDS1_8_A.cpp * * Created on: May 2, 2018 * Author: 13743 */ #include <cstdio> #include <cstdlib> struct Node { int key; Node *pa, *lc, *rc; }; Node *root = NULL; void insert(int k) { Node *y = NULL; Node *x = root; Node *z = new Node; while (x != NULL) { y = x; if (k < y->key) ...
replace
67
68
67
68
-11
p02284
C++
Time Limit Exceeded
#include <algorithm> #include <array> #include <cstdio> #include <iostream> #include <list> #include <numeric> #include <queue> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <map> #include <math.h> #define SENTINEL 1000000001 #define min...
#include <algorithm> #include <array> #include <cstdio> #include <iostream> #include <list> #include <numeric> #include <queue> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <map> #include <math.h> #define SENTINEL 1000000001 #define min...
replace
64
65
64
77
TLE
p02284
C++
Time Limit Exceeded
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; struct Node { int key; Node *parent, *left, *right; }; Node *root, *NIL; void insert(int k) { Node *y = NIL; Node *x = root; Node *z; z = (Node *)malloc(sizeof(Node)); z->key = k; z->left = NIL; z->righ...
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; struct Node { int key; Node *parent, *left, *right; }; Node *root, *NIL; void insert(int k) { Node *y = NIL; Node *x = root; Node *z; z = (Node *)malloc(sizeof(Node)); z->key = k; z->left = NIL; z->righ...
replace
48
49
48
49
TLE
p02284
C++
Time Limit Exceeded
#define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <cstdlib> using namespace std; int key[500000]; int left[500000]; int right[500000]; int root = -1; int numOfNodes = 0; void printInOrder(int i) { if (i == -1) { return; } printInOrder(left[i]); printf(" %d", key[i]); printInOrder(right[i]); } ...
#define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <cstdlib> using namespace std; int key[500000]; int left[500000]; int right[500000]; int root = -1; int numOfNodes = 0; void printInOrder(int i) { if (i == -1) { return; } printInOrder(left[i]); printf(" %d", key[i]); printInOrder(right[i]); } ...
replace
53
54
53
54
TLE
p02284
C++
Runtime Error
#include <iostream> #include <memory> #include <string> #include <vector> struct node { int key; std::weak_ptr<node> parent; std::shared_ptr<node> left; std::shared_ptr<node> right; node(int k) : key(k), left(nullptr), right(nullptr){}; }; class bst { private: std::shared_ptr<node> root; void r_inorder(...
#include <iostream> #include <memory> #include <string> #include <vector> struct node { int key; std::weak_ptr<node> parent; std::shared_ptr<node> left; std::shared_ptr<node> right; node(int k) : key(k), left(nullptr), right(nullptr){}; }; class bst { private: std::shared_ptr<node> root; void r_inorder(...
replace
53
54
53
54
-11
p02284
C++
Time Limit Exceeded
#include <assert.h> #include <climits> #include <iostream> #include <string> struct TNode { int Value; TNode *Parent; TNode *Left; TNode *Right; TNode(); TNode(int AValue, TNode *AParent); }; TNode::TNode() { Value = INT_MAX; Parent = NULL; Left = NULL; Right = NULL; } TNode::TNode(int AValue, T...
#include <assert.h> #include <climits> #include <iostream> #include <string> struct TNode { int Value; TNode *Parent; TNode *Left; TNode *Right; TNode(); TNode(int AValue, TNode *AParent); }; TNode::TNode() { Value = INT_MAX; Parent = NULL; Left = NULL; Right = NULL; } TNode::TNode(int AValue, T...
replace
77
78
77
80
TLE
p02284
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define mp...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define mp...
replace
66
71
66
74
TLE
p02284
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; vector<vector<int>> T; vector<long> v; void in(long k) { if (k == -1) return; else { in(T[k][0]); cout << " " << v[k]; in(T[k][1]); return; } } void pre(long k) { if (k == -1) return; e...
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; vector<vector<int>> T; vector<long> v; void in(long k) { if (k == -1) return; else { in(T[k][0]); cout << " " << v[k]; in(T[k][1]); return; } } void pre(long k) { if (k == -1) return; e...
replace
72
74
72
85
TLE
p02284
C++
Runtime Error
#include <cstdio> using namespace std; struct Node { Node *parent; Node *left; Node *right; int key; }; Node *NIL = NULL; void preorder(Node *v) { if (v == NIL) return; printf(" %d", v->key); preorder(v->left); preorder(v->right); } void inorder(Node *v) { if (v == NIL) return; inorder(v...
#include <cstdio> using namespace std; struct Node { Node *parent; Node *left; Node *right; int key; }; Node *NIL = NULL; void preorder(Node *v) { if (v == NIL) return; printf(" %d", v->key); preorder(v->left); preorder(v->right); } void inorder(Node *v) { if (v == NIL) return; inorder(v...
insert
81
81
81
83
0
p02284
C++
Time Limit Exceeded
#include "iostream" #include "vector" using namespace std; class branch { public: int key; branch *p; branch *left, *right; branch() {} branch(int key, branch *p) { this->key = key; this->p = p; this->left = NULL; this->right = NULL; } }; branch *tree; void insert(int z) { branch *buf; b...
#include "iostream" #include "vector" using namespace std; class branch { public: int key; branch *p; branch *left, *right; branch() {} branch(int key, branch *p) { this->key = key; this->p = p; this->left = NULL; this->right = NULL; } }; branch *tree; void insert(int z) { branch *buf; b...
replace
42
44
42
47
TLE
p02284
C++
Time Limit Exceeded
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; struct BINNODE { int key; BINNODE *parent; BINNODE *left; BINNODE *right; BINNODE(int k) { key = k; parent = nullptr; left = nullptr; right = nullptr; } }; void preorderwalk(BINNODE *root) { ...
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; struct BINNODE { int key; BINNODE *parent; BINNODE *left; BINNODE *right; BINNODE(int k) { key = k; parent = nullptr; left = nullptr; right = nullptr; } }; void preorderwalk(BINNODE *root) { ...
replace
43
44
43
44
TLE
p02284
C++
Runtime Error
#include <iostream> #include <string> using namespace std; struct node { int key; node *p, *l, *r; }; int n; node *N; void tree_insert(node *z) { node *y = NULL; node *x = N; while (x != NULL) { y = x; if (x->key > z->key) x = x->l; else if (x->key < z->key) x = x->r; } z->p = y...
#include <iostream> #include <string> using namespace std; struct node { int key; node *p, *l, *r; }; int n; node *N; void tree_insert(node *z) { node *y = NULL; node *x = N; while (x != NULL) { y = x; if (x->key > z->key) x = x->l; else if (x->key < z->key) x = x->r; } z->p = y...
replace
40
41
40
41
-11
p02285
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; struct Node { int key; Node *right, *left, *parent; }; Node *NIL; struct BST { Node *root; BST() { root = NIL; } void insert(int k) { Node *y = NIL; Node *x = root; Node *z = (Node *)malloc(sizeof(Node)); z->key = k; z->left = NIL; z->...
#include <bits/stdc++.h> using namespace std; struct Node { int key; Node *right, *left, *parent; }; Node *NIL; struct BST { Node *root; BST() { root = NIL; } void insert(int k) { Node *y = NIL; Node *x = root; Node *z = (Node *)malloc(sizeof(Node)); z->key = k; z->left = NIL; z->...
replace
78
79
78
84
0
p02285
C++
Runtime Error
#include <iostream> #include <vector> #define eol '\n'; using namespace std; class Node { public: int k; Node *p; Node *l; Node *r; Node() : k(-1), p(nullptr), l(nullptr), r(nullptr){}; }; Node *root; void insert(int k) { Node *y = nullptr; Node *x = root; while (x != nullptr) { y = x; if (k ...
#include <iostream> #include <vector> #define eol '\n'; using namespace std; class Node { public: int k; Node *p; Node *l; Node *r; Node() : k(-1), p(nullptr), l(nullptr), r(nullptr){}; }; Node *root; void insert(int k) { Node *y = nullptr; Node *x = root; while (x != nullptr) { y = x; if (k ...
replace
115
116
115
117
0
p02285
C++
Runtime Error
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string> using namespace std; struct Node { int key; Node *parent, *left, *right; }; Node *root, *NIL; void insert(int k) { Node *y = NIL; Node *x = root; Node *z; z = (Node *)malloc(sizeof(Node)); z->key = k; z->left = NIL; z->ri...
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string> using namespace std; struct Node { int key; Node *parent, *left, *right; }; Node *root, *NIL; void insert(int k) { Node *y = NIL; Node *x = root; Node *z; z = (Node *)malloc(sizeof(Node)); z->key = k; z->left = NIL; z->ri...
replace
91
92
91
92
0
p02285
C++
Runtime Error
#include <cstdio> #include <iostream> using namespace std; struct Node { int key; Node *parent, *left, *right; }; Node *root, *NIL; void insert(int k) { Node *y = NIL; Node *x = root; Node *z; z = new Node; z->key = k; z->left = NIL; z->right = NIL; while (x != NIL) { y = x; if (z->key ...
#include <cstdio> #include <iostream> using namespace std; struct Node { int key; Node *parent, *left, *right; }; Node *root, *NIL; void insert(int k) { Node *y = NIL; Node *x = root; Node *z; z = new Node; z->key = k; z->left = NIL; z->right = NIL; while (x != NIL) { y = x; if (z->key ...
replace
72
73
72
73
0
p02285
C++
Runtime Error
// Ref : https://book.mynavi.jp/ec/products/detail/id=35408 #include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; struct Node { int key; Node *parent, *left, *right; }; // These pointer adress is NULL until first store (root == NIL). // NIL adress is permanently NULL for...
// Ref : https://book.mynavi.jp/ec/products/detail/id=35408 #include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; struct Node { int key; Node *parent, *left, *right; }; // These pointer adress is NULL until first store (root == NIL). // NIL adress is permanently NULL for...
replace
106
107
106
107
0
p02285
C++
Runtime Error
#include <iostream> using namespace std; struct node { int key; node *left = NULL; node *right = NULL; node *parent = NULL; node(int k, node *l = NULL, node *r = NULL, node *p = NULL) : key(k), left(l), right(r), parent(p) {} }; node *Tree; void insert(int z) { node *y = NULL; node *x = Tree; whi...
#include <iostream> using namespace std; struct node { int key; node *left = NULL; node *right = NULL; node *parent = NULL; node(int k, node *l = NULL, node *r = NULL, node *p = NULL) : key(k), left(l), right(r), parent(p) {} }; node *Tree; void insert(int z) { node *y = NULL; node *x = Tree; whi...
delete
60
63
60
60
0
p02285
C++
Runtime Error
#include <algorithm> #include <cassert> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; // --------------------- // repetition #define FOR(i, a, b) for (...
#include <algorithm> #include <cassert> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; // --------------------- // repetition #define FOR(i, a, b) for (...
replace
109
111
109
117
0
p02285
C++
Runtime Error
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; // NIL is NULL #define NIL NULL // Node structure struct Node { int key; struct Node *parent; struct Node *leftc; struct Node *rightc; }; // define Nodepointer typedef struct Node *Nodepointer; // root Nodepointer ...
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; // NIL is NULL #define NIL NULL // Node structure struct Node { int key; struct Node *parent; struct Node *leftc; struct Node *rightc; }; // define Nodepointer typedef struct Node *Nodepointer; // root Nodepointer ...
delete
151
153
151
151
0
p02285
C++
Runtime Error
#include <iostream> #include <stdio.h> #include <string> struct Node { int key; Node *parent, *left, *right; }; Node *root, *NIL; int n; Node *getSuccessor(Node *u) { Node *x = u->right; while (x != NIL) { x = x->left; } return x; } void insert(int val) { Node *x = root; Node *y = NIL; Node *z...
#include <iostream> #include <stdio.h> #include <string> struct Node { int key; Node *parent, *left, *right; }; Node *root, *NIL; int n; Node *getSuccessor(Node *u) { Node *x = u->right; while (x->left != NIL) { x = x->left; } return x; } void insert(int val) { Node *x = root; Node *y = NIL; N...
replace
14
15
14
15
0
p02285
C++
Runtime Error
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; struct Node { int key; Node *right, *left, *parent; }; Node *root, *NIL; // 宣言時ポインタにはNULL(0x0)が入っているため, // 木の根が設定されていなければroot == NILとなる. void insert(int k) { Node *y = NIL; Node *x = root; Node...
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; struct Node { int key; Node *right, *left, *parent; }; Node *root, *NIL; // 宣言時ポインタにはNULL(0x0)が入っているため, // 木の根が設定されていなければroot == NILとなる. void insert(int k) { Node *y = NIL; Node *x = root; Node...
replace
83
89
83
87
0
p02285
C++
Runtime Error
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <list> #include <queue> #include <stack> #include <string.h> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <math.h> using namespace std; struct node { int key; node *parent, *left, *right; }; node *roo...
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <list> #include <queue> #include <stack> #include <string.h> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <math.h> using namespace std; struct node { int key; node *parent, *left, *right; }; node *roo...
replace
62
63
62
63
0
p02285
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define REP(i, n) for (int(i) = 0; (i) < (n); (i)++) using namespace std; class node { public: int key; node *left, *right, *parent; node() : key(0), lef...
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define REP(i, n) for (int(i) = 0; (i) < (n); (i)++) using namespace std; class node { public: int key; node *left, *right, *parent; node() : key(0), lef...
replace
104
105
104
105
0
p02285
C++
Runtime Error
// 二分探索木の削除 #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <stack> #include <vector> using namespace std; #define MAX_N 30 // const int NIL = -1; typedef struct node { // 節点の値 int key; // 節点の親 struct node *parent; // 節点の左の子 struc...
// 二分探索木の削除 #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <stack> #include <vector> using namespace std; #define MAX_N 30 // const int NIL = -1; typedef struct node { // 節点の値 int key; // 節点の親 struct node *parent; // 節点の左の子 struc...
replace
224
225
224
225
0
p02285
C++
Runtime Error
#include <iostream> #include <string> using namespace std; struct Node { int val; Node *parent; Node *left; Node *right; }; Node *nil; class Tree { Node *root; void preorder(Node *p) { if (p == nil) return; cout << " " << p->val; preorder(p->left); preorder(p->right); } void inor...
#include <iostream> #include <string> using namespace std; struct Node { int val; Node *parent; Node *left; Node *right; }; Node *nil; class Tree { Node *root; void preorder(Node *p) { if (p == nil) return; cout << " " << p->val; preorder(p->left); preorder(p->right); } void inor...
insert
50
50
50
51
0
p02285
C++
Runtime Error
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; // NIL is NULL #define NIL NULL // Node structure struct Node { int key; struct Node *parent; struct Node *leftc; struct Node *rightc; }; // define Nodepointer typedef struct Node *Nodepointer; // root Nodepointer ...
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; // NIL is NULL #define NIL NULL // Node structure struct Node { int key; struct Node *parent; struct Node *leftc; struct Node *rightc; }; // define Nodepointer typedef struct Node *Nodepointer; // root Nodepointer ...
delete
105
107
105
105
0
p02285
C++
Time Limit Exceeded
#include <stdio.h> struct binary_tree { int n; int l; int r; }; binary_tree bt[100]; int now = 0, empty[100]; void push(int n, int t) { if (now == 0) { bt[0].n = n; now++; return; } if (bt[t].n < n) { if (bt[t].r == 0) { bt[t].r = empty[now]; bt[bt[t].r].n = n; now++; ...
#include <stdio.h> struct binary_tree { int n; int l; int r; }; binary_tree bt[1000000]; int now = 0, empty[1000000]; void push(int n, int t) { if (now == 0) { bt[0].n = n; now++; return; } if (bt[t].n < n) { if (bt[t].r == 0) { bt[t].r = empty[now]; bt[bt[t].r].n = n; now+...
replace
6
8
6
8
TLE
p02285
C++
Runtime Error
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; // NIL is NULL #define NIL NULL // Node structure struct Node { int key; struct Node *parent; struct Node *leftc; struct Node *rightc; }; // define Nodepointer typedef struct Node *Nodepointer; // root Nodepointer ...
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; // NIL is NULL #define NIL NULL // Node structure struct Node { int key; struct Node *parent; struct Node *leftc; struct Node *rightc; }; // define Nodepointer typedef struct Node *Nodepointer; // root Nodepointer ...
delete
102
103
102
102
0
p02285
C++
Runtime Error
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; // NIL is NULL #define NIL NULL // Node structure struct Node { int key; struct Node *parent; struct Node *leftc; struct Node *rightc; }; // define Nodepointer typedef struct Node *Nodepointer; // root Nodepointer ...
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; // NIL is NULL #define NIL NULL // Node structure struct Node { int key; struct Node *parent; struct Node *leftc; struct Node *rightc; }; // define Nodepointer typedef struct Node *Nodepointer; // root Nodepointer ...
delete
102
103
102
102
0
p02285
C++
Runtime Error
#include <assert.h> #include <iostream> #include <string> using namespace std; struct Node { int iKey_; Node *pParent_; Node *pLeftChild_; Node *pRightChild_; }; class Tree { public: Tree(int iNum) : iMaxNodeNum_(iNum), iCurNodeNum_(0) {} void setNodeValue() { for (int iCurNode_i = 0; iCurNode_i < iM...
#include <assert.h> #include <iostream> #include <string> using namespace std; struct Node { int iKey_; Node *pParent_; Node *pLeftChild_; Node *pRightChild_; }; class Tree { public: Tree(int iNum) : iMaxNodeNum_(iNum), iCurNodeNum_(0) {} void setNodeValue() { for (int iCurNode_i = 0; iCurNode_i < iM...
replace
125
126
125
126
0
p02285
C++
Runtime Error
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; // NIL is NULL #define NIL NULL // Node structure struct Node { int key; struct Node *parent; struct Node *leftc; struct Node *rightc; }; // define Nodepointer typedef struct Node *Nodepointer; // root Nodepointer ...
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; // NIL is NULL #define NIL NULL // Node structure struct Node { int key; struct Node *parent; struct Node *leftc; struct Node *rightc; }; // define Nodepointer typedef struct Node *Nodepointer; // root Nodepointer ...
delete
104
105
104
104
0
p02286
C++
Runtime Error
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; /* struct Node{ Node *right, *left; int key, priority; }; Node* node(int k, int p){ Node *newNode = new Node();//(Node *)malloc(sizeof(Node)); newNode->right = NULL; newNode->left = NULL; newNode->key = k; ne...
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; /* struct Node{ Node *right, *left; int key, priority; }; Node* node(int k, int p){ Node *newNode = new Node();//(Node *)malloc(sizeof(Node)); newNode->right = NULL; newNode->left = NULL; newNode->key = k; ne...
replace
145
146
145
146
-11
p02287
C++
Runtime Error
#include <iostream> using namespace std; typedef long long signed int ll; ll a[251]; int h; void rk(int n) { if (a[n * 2 + 1]) cout << "right key = " << a[n * 2 + 1] << ", "; } void lk(int n) { if (a[n * 2]) cout << "left key = " << a[n * 2] << ", "; } void pk(int n) { if (a[n / 2]) cout << "paren...
#include <iostream> using namespace std; typedef long long signed int ll; ll a[510]; int h; void rk(int n) { if (a[n * 2 + 1]) cout << "right key = " << a[n * 2 + 1] << ", "; } void lk(int n) { if (a[n * 2]) cout << "left key = " << a[n * 2] << ", "; } void pk(int n) { if (a[n / 2]) cout << "paren...
replace
6
7
6
7
0
p02287
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; struct Node { int key; int id, parent, left, right; }; Node A[251]; void heap(Node A[], int H) { for (int i = 1; i <= H; i++) { if (i == 1) { A[i].left = A[2 * i].key; A[i].right = A[2 * i + 1].key; } else { A[i].parent = A[i / 2].key; ...
#include <bits/stdc++.h> using namespace std; struct Node { int key; int id, parent, left, right; }; Node A[100000]; void heap(Node A[], int H) { for (int i = 1; i <= H; i++) { if (i == 1) { A[i].left = A[2 * i].key; A[i].right = A[2 * i + 1].key; } else { A[i].parent = A[i / 2].key; ...
replace
7
8
7
8
0
p02288
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <stdio.h> #include <string> #include <vector> #define MAX 1000000000000000000LL long long inf = 1000000007; using namespace std; int H, A[200001]; void maxheapify(int i) { int l, r, largest; l = 2 * i; r = 2 * i + 1; if (l <=...
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <stdio.h> #include <string> #include <vector> #define MAX 1000000000000000000LL long long inf = 1000000007; using namespace std; int H, A[2000001]; void maxheapify(int i) { int l, r, largest; l = 2 * i; r = 2 * i + 1; if (l <...
replace
10
11
10
11
0
p02288
C++
Runtime Error
#define scanf_s scanf #include <algorithm> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; #define MAX 500 // 000 // #define MAX_ 1000 static int H; void maxHeapify(long long int A[], int ...
#define scanf_s scanf #include <algorithm> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; #define MAX 500000 // #define MAX_ 1000 static int H; void maxHeapify(long long int A[], int i) {...
replace
13
14
13
14
0
p02288
C++
Runtime Error
#include <cstdio> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define MAX_V 250 int heap[MAX_V]{0}; int left(int i) { return 2 * i + 1; } int right(int i) { return 2 * i + 2; } int parent(int i) { return (i - 1) / 2; } bool has_left(int size, int i) { return size > lef...
#include <cstdio> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define MAX_V 500000 int heap[MAX_V]{0}; int left(int i) { return 2 * i + 1; } int right(int i) { return 2 * i + 2; } int parent(int i) { return (i - 1) / 2; } bool has_left(int size, int i) { return size > ...
replace
4
5
4
5
0
p02288
C++
Runtime Error
#include <iostream> #include <stdio.h> #define MAX 1000000 int n, H[MAX]; void maxHeap(int i) { int left = i * 2; int right = i * 2 + 1; int max = left; if (right <= n) max = H[left] >= H[right] ? left : right; max = H[i] >= H[max] ? i : max; if (max != i) { std::swap(H[i], H[max]); maxHeap...
#include <iostream> #include <stdio.h> #define MAX 1000000 int n, H[MAX]; void maxHeap(int i) { int left = i * 2; int right = i * 2 + 1; if (left > n) return; int max = left; if (right <= n) max = H[left] >= H[right] ? left : right; max = H[i] >= H[max] ? i : max; if (max != i) { std::sw...
insert
10
10
10
13
0
p02288
C++
Runtime Error
#include <iostream> using namespace std; const int MAX = 100000; int H, i, A[MAX + 1]; int parent(int i) { return i / 2; } int left(int i) { return 2 * i; } int right(int i) { return 2 * i + 1; } void maxHeapify(int *A, int i) { int l = left(i); int r = right(i); int largest; if (l <= H && A[l] > A[i]) { ...
#include <iostream> using namespace std; const int MAX = 500000; int H, i, A[MAX + 1]; int parent(int i) { return i / 2; } int left(int i) { return 2 * i; } int right(int i) { return 2 * i + 1; } void maxHeapify(int *A, int i) { int l = left(i); int r = right(i); int largest; if (l <= H && A[l] > A[i]) { ...
replace
3
4
3
4
0
p02288
C++
Runtime Error
#include <algorithm> #include <cassert> #include <iostream> #include <vector> int left(int i) { return i * 2; } int right(int i) { return i * 2 + 1; } void maxHeapify(std::vector<int> &A, int i) { int H = A.size() + 1; int l = left(i); int r = right(i); int largest; if (l <= H && A[l] > A[i]) { largest =...
#include <algorithm> #include <cassert> #include <iostream> #include <vector> int left(int i) { return i * 2; } int right(int i) { return i * 2 + 1; } void maxHeapify(std::vector<int> &A, int i) { int H = A.size(); int l = left(i); int r = right(i); int largest; if (l <= H && A[l] > A[i]) { largest = l; ...
replace
8
9
8
9
0
p02288
C++
Runtime Error
#include <iostream> #include <stdio.h> #define abs(a) (a < 0 ? -(a) : a) #define square(x) ((x) * (x)) #define max(a, b) ((a) > (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b)) #define swap(a, b) ((a != b) ? (a += b, b = a - b, a -= b) : 0) #define This #define True true #define False false #define null Null...
#include <iostream> #include <stdio.h> #define abs(a) (a < 0 ? -(a) : a) #define square(x) ((x) * (x)) #define max(a, b) ((a) > (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b)) #define swap(a, b) ((a != b) ? (a += b, b = a - b, a -= b) : 0) #define This #define True true #define False false #define null Null...
replace
45
46
45
46
0
p02288
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; void f(const int, const int, int *); int main() { int N; i...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; void f(const int, const int, int *); int main() { int N; i...
replace
20
21
20
21
0
p02288
C++
Runtime Error
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; int D[10000]; int H[10000]; void printResult(int i, int n) { printf("node %d: key = %d, ", i, H[i]); if (i != 1) printf("parent key = %d, ", H[i / 2]); if (2 * i <= n) printf("left key = %d, ", H[2 * i]); i...
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; int H[500001]; void printResult(int i, int n) { printf("node %d: key = %d, ", i, H[i]); if (i != 1) printf("parent key = %d, ", H[i / 2]); if (2 * i <= n) printf("left key = %d, ", H[2 * i]); if (2 * i + 1 ...
replace
6
8
6
7
0
p02288
C++
Time Limit Exceeded
#include <cstdio> #include <iostream> #define MAX 2000000 using namespace std; int H, a[MAX + 1]; void max(int i) { int l, r, large; l = 2 * i; r = 2 * i + 1; if (l <= H && a[l] > a[i]) large = 1; else large = i; if (r <= H && a[r] > a[large]) large = r; if (large != i) { swap(a[i], a[larg...
#include <cstdio> #include <iostream> #define MAX 2000000 using namespace std; int H, a[MAX + 1]; void max(int i) { int l, r, large; l = 2 * i; r = 2 * i + 1; if (l <= H && a[l] > a[i]) large = l; else large = i; if (r <= H && a[r] > a[large]) large = r; if (large != i) { swap(a[i], a[larg...
replace
10
11
10
11
TLE
p02288
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int A[260], H; void maxHeapify(int i) { int l = i * 2; int r = i * 2 + 1; int largest; if (l <= H && A[l] > A[i]) largest = l; else largest = i; if (r <= H && A[r] > A[largest]) largest = r; if (largest != i) { swap(A[i], A[largest]); ma...
#include <bits/stdc++.h> using namespace std; int A[500010], H; void maxHeapify(int i) { int l = i * 2; int r = i * 2 + 1; int largest; if (l <= H && A[l] > A[i]) largest = l; else largest = i; if (r <= H && A[r] > A[largest]) largest = r; if (largest != i) { swap(A[i], A[largest]); ...
replace
2
3
2
3
0
p02288
C++
Runtime Error
#include <cstdio> #include <iostream> #include <math.h> using namespace std; int p[250]; int id, q; int k; int parent(int i) { if (i % 2 == 0) { return i / 2; } else { return (i - 1) / 2; } } int left(int i) { return 2 * i; } int right(int i) { return 2 * i + 1; } int inside(int i) { if (i > id || ...
#include <cstdio> #include <iostream> #include <math.h> using namespace std; int p[500000]; int id, q; int k; int parent(int i) { if (i % 2 == 0) { return i / 2; } else { return (i - 1) / 2; } } int left(int i) { return 2 * i; } int right(int i) { return 2 * i + 1; } int inside(int i) { if (i > id ...
replace
5
6
5
6
0
p02288
C++
Runtime Error
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; const int maxx = 200000; int A[maxx + 1]; int n; void maxHeapify(int i) { int left = 2 * i, right = 2 * i + 1; int largest; // ?????????????????????????????????????????????????????§??????????????¶?????§??????????????? if (left <=...
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; const int maxx = 2000000; int A[maxx + 1]; int n; void maxHeapify(int i) { int left = 2 * i, right = 2 * i + 1; int largest; // ?????????????????????????????????????????????????????§??????????????¶?????§??????????????? if (left <...
replace
4
5
4
5
0
p02288
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; struct Node { int key; int id, parent, left, right; }; Node A[100000]; int H; void heap(int H) { for (int i = 1; i <= H; i++) { if (i == 1) { A[i].left = A[2 * i].key; A[i].right = A[2 * i + 1].key; } else { A[i].parent = A[i / 2].key; ...
#include <bits/stdc++.h> using namespace std; struct Node { int key; int id, parent, left, right; }; Node A[20000000]; int H; void heap(int H) { for (int i = 1; i <= H; i++) { if (i == 1) { A[i].left = A[2 * i].key; A[i].right = A[2 * i + 1].key; } else { A[i].parent = A[i / 2].key; ...
replace
7
8
7
8
0
p02288
C++
Runtime Error
#include <iostream> #include <queue> #include <stack> #include <stdio.h> #include <string> #include <vector> #define N 251 #define NIL 2000000001 using namespace std; int n; void swap(int *, int *); void maxHeapify(int[], int); void buildMaxHeap(int[]); int main() { int heap[N]; cin >> n; for (int i = 1; i <= ...
#include <iostream> #include <queue> #include <stack> #include <stdio.h> #include <string> #include <vector> #define N 500000 #define NIL 2000000001 using namespace std; int n; void swap(int *, int *); void maxHeapify(int[], int); void buildMaxHeap(int[]); int main() { int heap[N]; cin >> n; for (int i = 1; i ...
replace
6
7
6
7
0
p02288
C++
Runtime Error
#include <bits/stdc++.h> #define reps(i, s, n) for (int i = (s); i <= (n); ++i) using namespace std; int H, heap[200001]; void maxHeapify(int i) { int l, r, largest; l = i * 2; r = i * 2 + 1; // 左の子、自分、右の子の中で最大のノードを選ぶ if (l <= H && heap[l] > heap[i]) largest = l; else largest = i; if (r <= H &...
#include <bits/stdc++.h> #define reps(i, s, n) for (int i = (s); i <= (n); ++i) using namespace std; int H, heap[500010]; void maxHeapify(int i) { int l, r, largest; l = i * 2; r = i * 2 + 1; // 左の子、自分、右の子の中で最大のノードを選ぶ if (l <= H && heap[l] > heap[i]) largest = l; else largest = i; if (r <= H &...
replace
4
5
4
5
0
p02288
C++
Runtime Error
#include <algorithm> #include <iostream> using namespace std; int n; int parent(int i); int left(int i); int right(int i); void maxHeap(int node[], int i); void buildMaxHeap(int node[]); int main() { int i, node[252]; cin >> n; for (i = 1; i <= n; i++) cin >> node[i]; buildMaxHeap(node); for (i = 1; ...
#include <algorithm> #include <iostream> using namespace std; int n; int parent(int i); int left(int i); int right(int i); void maxHeap(int node[], int i); void buildMaxHeap(int node[]); int main() { int i, node[500000]; cin >> n; for (i = 1; i <= n; i++) cin >> node[i]; buildMaxHeap(node); for (i = ...
replace
13
14
13
14
0
p02288
C++
Runtime Error
#include <stdio.h> #define N 250 int it = 0, n, tree[N + 1]; void swapInt(int *x, int *y) { int tmp = *x; *x = *y; *y = tmp; } void maxHeap(int u) { int left, right, largest; left = u * 2; right = u * 2 + 1; if (left <= it && tree[u] < tree[left]) largest = left; else largest = u; if (right ...
#include <stdio.h> #define N 500000 int it = 0, n, tree[N + 1]; void swapInt(int *x, int *y) { int tmp = *x; *x = *y; *y = tmp; } void maxHeap(int u) { int left, right, largest; left = u * 2; right = u * 2 + 1; if (left <= it && tree[u] < tree[left]) largest = left; else largest = u; if (rig...
replace
1
2
1
2
0
p02288
C++
Runtime Error
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; typedef long long ll; #define INF 2139062143 void heap(int); int arr[300]; int n; int main(int argc, char *argv[]) { memset(arr, 127, sizeof(arr)); // input cin >> n; for (int i = 1; i <= n; i++) cin >> a...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; typedef long long ll; #define INF 2139062143 void heap(int); int arr[500001]; int n; int main(int argc, char *argv[]) { memset(arr, 127, sizeof(arr)); // input cin >> n; for (int i = 1; i <= n; i++) cin >...
replace
11
12
11
12
0
p02288
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int H, A[500001] = {}; void mh(int i) { int l = i * 2, r = i * 2 + 1, lar = i; if (A[l] > A[i] && l <= H) lar = l; if (A[r] > A[lar] && r <= H) lar = r; if (lar != i) { swap(A[lar], A[i]); mh(lar); } } int main() { cin >> H; for (int i = 1; ...
#include <bits/stdc++.h> using namespace std; int H, A[5000001] = {}; void mh(int i) { int l = i * 2, r = i * 2 + 1, lar = i; if (A[l] > A[i] && l <= H) lar = l; if (A[r] > A[lar] && r <= H) lar = r; if (lar != i) { swap(A[lar], A[i]); mh(lar); } } int main() { cin >> H; for (int i = 1;...
replace
2
3
2
3
0
p02288
C++
Runtime Error
#include <iostream> using namespace std; #define MAX 200000 int H, A[MAX + 1]; void maxHeapify(int i) { int l, r, largest, tmp; l = 2 * i; r = 2 * i + 1; if (l <= H && A[l] > A[i]) { largest = l; } else { largest = i; } if (r <= H && A[r] > A[largest]) { largest = r; } if (largest != i...
#include <iostream> using namespace std; #define MAX 2000000 int H, A[MAX + 1]; void maxHeapify(int i) { int l, r, largest, tmp; l = 2 * i; r = 2 * i + 1; if (l <= H && A[l] > A[i]) { largest = l; } else { largest = i; } if (r <= H && A[r] > A[largest]) { largest = r; } if (largest != ...
replace
2
3
2
3
0
p02288
C++
Runtime Error
#include <stdio.h> long long int a[100]; int x; void build(int n) { long long int temp; int top = n, l = n * 2, r = n * 2 + 1; if (a[r] > a[n] && r <= x) top = r; if (a[l] > a[top] && l <= x) top = l; if (top != n) { temp = a[top]; a[top] = a[n]; a[n] = temp; build(top); } } int main...
#include <stdio.h> long long int a[1000000]; int x; void build(int n) { long long int temp; int top = n, l = n * 2, r = n * 2 + 1; if (a[r] > a[n] && r <= x) top = r; if (a[l] > a[top] && l <= x) top = l; if (top != n) { temp = a[top]; a[top] = a[n]; a[n] = temp; build(top); } } int ...
replace
1
2
1
2
0
p02288
C++
Runtime Error
#include <iostream> using namespace std; int n; int H[251]; void buildMaxHeap(void); void maxHeapify(int); int main() { cin >> n; for (int i = 1; i < n + 1; ++i) { cin >> H[i]; } buildMaxHeap(); for (int i = 1; i < n + 1; ++i) { cout << " " << H[i] << flush; } cout << endl; return 0; } void b...
#include <iostream> using namespace std; int n; int H[5000000]; void buildMaxHeap(void); void maxHeapify(int); int main() { cin >> n; for (int i = 1; i < n + 1; ++i) { cin >> H[i]; } buildMaxHeap(); for (int i = 1; i < n + 1; ++i) { cout << " " << H[i] << flush; } cout << endl; return 0; } vo...
replace
3
4
3
4
0
p02288
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int A[250 + 1], h; int parent(int i) { return i / 2; } int left(int i) { return i * 2; } int right(int i) { return i * 2 + 1; } void maxHeap(int i) { int l = left(i), r = right(i); int largest; if (l <= h && A[l] > A[i]) largest = l; else largest = i; ...
#include <bits/stdc++.h> using namespace std; int A[500000 + 1], h; int parent(int i) { return i / 2; } int left(int i) { return i * 2; } int right(int i) { return i * 2 + 1; } void maxHeap(int i) { int l = left(i), r = right(i); int largest; if (l <= h && A[l] > A[i]) largest = l; else largest = i...
replace
2
3
2
3
0
p02288
C++
Runtime Error
#include <stdio.h> void max_heapify(int *a, int i, int n) { int j, temp; temp = a[i]; j = 2 * i; while (j <= n) { if (j < n && a[j + 1] > a[j]) j = j + 1; if (temp > a[j]) break; else if (temp <= a[j]) { a[j / 2] = a[j]; j = 2 * j; } } a[j / 2]...
#include <stdio.h> void max_heapify(int *a, int i, int n) { int j, temp; temp = a[i]; j = 2 * i; while (j <= n) { if (j < n && a[j + 1] > a[j]) j = j + 1; if (temp > a[j]) break; else if (temp <= a[j]) { a[j / 2] = a[j]; j = 2 * j; } } a[j / 2]...
replace
62
63
62
63
0
p02288
C++
Runtime Error
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <cmath> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) using namespace std; typedef long ...
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <cmath> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) using namespace std; typedef long ...
replace
16
17
16
17
0
p02288
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long lli; typedef vector<lli> vll; typedef vector<bool> vbl; typedef vector<vector<lli>> mat;...
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long lli; typedef vector<lli> vll; typedef vector<bool> vbl; typedef vector<vector<lli>> mat;...
replace
27
28
27
34
-6
Fatal glibc error: malloc assertion failure in sysmalloc: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)
p02288
C++
Runtime Error
#include <iostream> #include <stdio.h> #define NUM 100000000 #define NIL -2000000001 using namespace std; void print(int *heap, int H) { for (int i = 0; i < H; i++) { printf(" %d", heap[i + 1]); } printf("\n"); } int left(int i) { return i * 2; } int right(int i) { return i * 2 + 1; } int largest_(int *he...
#include <iostream> #include <stdio.h> #define NUM 10000000 #define NIL -2000000001 using namespace std; void print(int *heap, int H) { for (int i = 0; i < H; i++) { printf(" %d", heap[i + 1]); } printf("\n"); } int left(int i) { return i * 2; } int right(int i) { return i * 2 + 1; } int largest_(int *hea...
replace
2
3
2
3
-11
p02288
C++
Runtime Error
#include <iostream> using namespace std; int H; int left(int i) { return 2 * i; } int right(int i) { return 2 * i + 1; } void maxHeapify(int *A, int i) { int l = left(i); int r = right(i); int largest; if (l <= H && A[i] < A[l]) { largest = l; } else { largest = i; } if (r <= H && A[largest] < ...
#include <iostream> using namespace std; int H; int left(int i) { return 2 * i; } int right(int i) { return 2 * i + 1; } void maxHeapify(int *A, int i) { int l = left(i); int r = right(i); int largest; if (l <= H && A[i] < A[l]) { largest = l; } else { largest = i; } if (r <= H && A[largest] < ...
replace
33
34
33
34
0
p02288
C++
Runtime Error
#include <cmath> #include <iostream> constexpr size_t MAX_HEAP_SIZE = 250; int H[MAX_HEAP_SIZE + 1]; int parent(int i) { return i / 2; } int left(int i) { return i * 2; } int right(int i) { return i * 2 + 1; } int MaxHeapify(int *H, int i, int heap_size) { int l = left(i); int r = right(i); int largest; if...
#include <cmath> #include <iostream> constexpr size_t MAX_HEAP_SIZE = 500000; ; int H[MAX_HEAP_SIZE + 1]; int parent(int i) { return i / 2; } int left(int i) { return i * 2; } int right(int i) { return i * 2 + 1; } int MaxHeapify(int *H, int i, int heap_size) { int l = left(i); int r = right(i); int largest;...
replace
3
4
3
5
0
p02288
C++
Runtime Error
#include <cstdio> #include <iostream> constexpr int MAXN = 250; int Heap[MAXN + 1]; int parent(int i) { return i / 2; } int left(int i) { return i * 2; } int right(int i) { return i * 2 + 1; } #define FOR(i, a, b) for (int i = (a); i < (b); i++) int n; void ShowHeap(int *Heap) { FOR(i, 1, n + 1) { std::printf...
#include <cstdio> #include <iostream> constexpr int MAXN = 500000; int Heap[MAXN + 1]; int parent(int i) { return i / 2; } int left(int i) { return i * 2; } int right(int i) { return i * 2 + 1; } #define FOR(i, a, b) for (int i = (a); i < (b); i++) int n; void ShowHeap(int *Heap) { FOR(i, 1, n + 1) { std::pri...
replace
3
4
3
4
0
p02288
C++
Runtime Error
#include <iostream> using namespace std; #define MAX 2000000 int gHeap[MAX + 1], gSize; void maxHeapify(int i) { int left, right, largest; left = 2 * i; right = 2 * i + 1; // 左の子、自分、右の子で値が最大のノードを選択 if (left <= gSize && gHeap[left] > gHeap[i]) { largest = left; } else { largest = i; } // 右の子と比...
#include <iostream> using namespace std; #define MAX 2000000 int gHeap[MAX + 1], gSize; void maxHeapify(int i) { int left, right, largest; left = 2 * i; right = 2 * i + 1; // 左の子、自分、右の子で値が最大のノードを選択 if (left <= gSize && gHeap[left] > gHeap[i]) { largest = left; } else { largest = i; } // 右の子と比...
replace
32
34
32
34
0
p02288
C++
Runtime Error
#include <algorithm> #include <iostream> using namespace std; int main(void) { int n; int a[250]; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; make_heap(a, a + n); for (int i = 0; i < n; i++) { cout << " " << a[i]; } cout << endl; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main(void) { int n; int a[500000]; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; make_heap(a, a + n); for (int i = 0; i < n; i++) { cout << " " << a[i]; } cout << endl; return 0; }
replace
6
7
6
7
0
p02289
C++
Time Limit Exceeded
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; int H[2000001]; void printResult(int i, int n) { printf("node %d: key = %d, ", i, H[i]); if (i != 1) printf("parent key = %d, ", H[i / 2]); if (2 * i <= n) printf("left key = %d, ", H[2 * i]); if (2 * i + 1...
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; int H[2000001]; void printResult(int i, int n) { printf("node %d: key = %d, ", i, H[i]); if (i != 1) printf("parent key = %d, ", H[i / 2]); if (2 * i <= n) printf("left key = %d, ", H[2 * i]); if (2 * i + 1...
replace
59
60
59
60
TLE
p02289
C++
Runtime Error
#include <iostream> using namespace std; typedef long long signed int ll; constexpr ll NIL = -20000000000; ll a[500010] = {NIL}; int h; ll rk(int n) { if (n * 2 + 1 <= h) return a[n * 2 + 1]; return NIL; } ll lk(int n) { if (n * 2 <= h) return a[n * 2]; return NIL; } ll pk(int n) { if (n / 2 <= h...
#include <iostream> using namespace std; typedef long long signed int ll; constexpr ll NIL = -20000000000; ll a[20000000] = {NIL}; int h; ll rk(int n) { if (n * 2 + 1 <= h) return a[n * 2 + 1]; return NIL; } ll lk(int n) { if (n * 2 <= h) return a[n * 2]; return NIL; } ll pk(int n) { if (n / 2 <=...
replace
8
9
8
9
0
p02289
C++
Runtime Error
#include <stdio.h> #include <string> void max_heapify(int *A, int i, int H) { int l = 2 * i, r = 2 * i + 1; if (l > H && r > H) return; int maxid = i, x; if (l <= H) { if (A[l] > A[maxid]) maxid = l; } if (r <= H) { if (A[r] > A[maxid]) maxid = r; } if (maxid == i) return; ...
#include <stdio.h> #include <string> void max_heapify(int *A, int i, int H) { int l = 2 * i, r = 2 * i + 1; if (l > H && r > H) return; int maxid = i, x; if (l <= H) { if (A[l] > A[maxid]) maxid = l; } if (r <= H) { if (A[r] > A[maxid]) maxid = r; } if (maxid == i) return; ...
replace
25
26
25
26
0
p02289
C++
Runtime Error
#include <stdio.h> #include <string> void max_heapify(int *A, int i, int H) { int l = 2 * i, r = 2 * i + 1; if (l > H && r > H) return; int maxid = i, x; if (l <= H) maxid = (A[l] > A[maxid] ? l : maxid); if (r <= H) maxid = (A[r] > A[maxid] ? r : maxid); if (maxid == i) return; x = A[max...
#include <stdio.h> #include <string> void max_heapify(int *A, int i, int H) { int l = 2 * i, r = 2 * i + 1; if (l > H && r > H) return; int maxid = i, x; if (l <= H) maxid = (A[l] > A[maxid] ? l : maxid); if (r <= H) maxid = (A[r] > A[maxid] ? r : maxid); if (maxid == i) return; x = A[max...
replace
21
22
21
22
0
p02289
C++
Runtime Error
#include <cassert> #include <cstdint> #include <cstdlib> #include <utility> /* template<typename T, bool P = false> class PairingHeap; PairingHeapは融合可能なヒープ(優先度付きキュー)です 空間計算量 O(N) テンプレートパラメータ -typename T operator< によって大小が定義された構造体 要素の型になります -bool P true を与えると最大ヒープになります デフォルトでは false で最小ヒープです メンバ関数 -(constructor) (...
#include <cassert> #include <cstdint> #include <cstdlib> #include <utility> /* template<typename T, bool P = false> class PairingHeap; PairingHeapは融合可能なヒープ(優先度付きキュー)です 空間計算量 O(N) テンプレートパラメータ -typename T operator< によって大小が定義された構造体 要素の型になります -bool P true を与えると最大ヒープになります デフォルトでは false で最小ヒープです メンバ関数 -(constructor) (...
replace
270
271
270
271
-6
63082062-9b26-4ab1-bd24-ca43547ed4c5.out: /home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02289/C++/s646044302.cpp:158: void PairingHeap<T, P>::decrease(node_t*, const T&) [with T = long unsigned int; bool P = true]: Assertion `!(P ^ (x->data < data))' failed.
p02289
C++
Time Limit Exceeded
// #define NDEBUG #define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <array> #include <cassert> #include <climits> #include <cmath> #include <cstdint> #include <cstdio> #include <cstdlib> #include <ctime> #include <functional> #include <map> #include <queue> #include <set> #include <stack> #include <string> ...
// #define NDEBUG #define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <array> #include <cassert> #include <climits> #include <cmath> #include <cstdint> #include <cstdio> #include <cstdlib> #include <ctime> #include <functional> #include <map> #include <queue> #include <set> #include <stack> #include <string> ...
replace
49
50
49
50
TLE
p02289
C++
Runtime Error
#include <algorithm> #include <cassert> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; // --------------------- // repetition #define FOR(i, a, b) for (...
#include <algorithm> #include <cassert> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; // --------------------- // repetition #define FOR(i, a, b) for (...
replace
86
87
86
87
0
p02289
C++
Time Limit Exceeded
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; #define MAX 2000000 #define INFTY (1 << 30) int H, A[MAX + 1]; void maxHeap(int i) { int l, r, large; l = 2 * i; r = 2 * i + 1; if (l <= H && A[l] > A[i]) { large = l; } else { large = i; } if (r ...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; #define MAX 2000000 #define INFTY (1 << 30) int H, A[MAX + 1]; void maxHeap(int i) { int l, r, large; l = 2 * i; r = 2 * i + 1; if (l <= H && A[l] > A[i]) { large = l; } else { large = i; } if (r ...
replace
56
57
56
57
TLE
p02289
C++
Runtime Error
#include <algorithm> #include <stdio.h> using namespace std; int val, size_, heap[2097168]; char c[9]; inline void insert(int x) { int ptr = size_++; heap[ptr] = x; while (ptr > 1) { if (heap[ptr >> 1] < heap[ptr]) swap(heap[ptr], heap[ptr >> 1]); ptr >>= 1; } } inline int extract() { int ret = ...
#include <algorithm> #include <stdio.h> using namespace std; int val, size_, heap[2097168]; char c[9]; inline void insert(int x) { int ptr = size_++; heap[ptr] = x; while (ptr > 1) { if (heap[ptr >> 1] < heap[ptr]) swap(heap[ptr], heap[ptr >> 1]); ptr >>= 1; } } inline int extract() { int ret = ...
replace
33
34
33
34
TLE
p02289
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <list> #include <set> #include <stack> #include <vector> using namespace std; #define REP(i, n) for (int(i) = 0; (i) < (n); (i)++) #define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++) #define PUSH(n, v) ...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <list> #include <set> #include <stack> #include <vector> using namespace std; #define REP(i, n) for (int(i) = 0; (i) < (n); (i)++) #define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++) #define PUSH(n, v) ...
insert
118
118
118
119
TLE
p02289
C++
Runtime Error
#include <cstdio> #include <iostream> #include <math.h> using namespace std; int p[250]; int id, q; int k; int parent(int i) { if (i % 2 == 0) { return i / 2; } else { return (i - 1) / 2; } } int left(int i) { return 2 * i; } int right(int i) { return 2 * i + 1; } int inside(int i) { if (i > id || ...
#include <cstdio> #include <iostream> #include <math.h> using namespace std; int p[2000000]; int id, q; int k; int parent(int i) { if (i % 2 == 0) { return i / 2; } else { return (i - 1) / 2; } } int left(int i) { return 2 * i; } int right(int i) { return 2 * i + 1; } int inside(int i) { if (i > id...
replace
5
6
5
6
0
p02289
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using Int = long long; #include <bits/stdc++.h> using namespace std; using Int = long long; // BEGIN CUT HERE template <typename T, typename E> struct SkewHeap { using F = function<T(T, T)>; using G = function<T(T, E)>; using C = function<bool(T, T)>; F f; G g; ...
#include <bits/stdc++.h> using namespace std; using Int = long long; #include <bits/stdc++.h> using namespace std; using Int = long long; // BEGIN CUT HERE template <typename T, typename E> struct SkewHeap { using F = function<T(T, T)>; using G = function<T(T, E)>; using C = function<bool(T, T)>; F f; G g; ...
replace
198
200
198
200
0
p02289
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using Int = long long; #include <bits/stdc++.h> using namespace std; using Int = long long; // BEGIN CUT HERE template <typename T, typename E> struct FGC { typedef function<T(T, E)> F; typedef function<E(E, E)> G; typedef function<bool(T, T)> C; F &f; G &g; C &...
#include <bits/stdc++.h> using namespace std; using Int = long long; #include <bits/stdc++.h> using namespace std; using Int = long long; // BEGIN CUT HERE template <typename T, typename E> struct FGC { typedef function<T(T, E)> F; typedef function<E(E, E)> G; typedef function<bool(T, T)> C; F &f; G &g; C &...
insert
63
63
63
65
TLE
p02289
C++
Time Limit Exceeded
#include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define MAX_V 5000000 int heap[MAX_V]{0}; int heap_size = 0; int left(int i) { return 2 * i + 1; } int right(int i) { return 2 * i + 2; } int parent(int i) { return (i - 1) / 2; } bool has_left(int i) { return heap_size > lef...
#include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define MAX_V 5000000 int heap[MAX_V]{0}; int heap_size = 0; int left(int i) { return 2 * i + 1; } int right(int i) { return 2 * i + 2; } int parent(int i) { return (i - 1) / 2; } bool has_left(int i) { return heap_size > lef...
insert
51
51
51
53
TLE
p02289
C++
Runtime Error
#include <algorithm> #include <iostream> #include <string> using namespace std; #define MAX 1000000 class PriorityQueue { public: int size; int buffer[MAX + 1]; PriorityQueue() { size = 0; } void insert(int x) { size++; buffer[size] = x; upHeap(size); } int get() { int v = buffer[1]; ...
#include <algorithm> #include <iostream> #include <string> using namespace std; #define MAX 2000000 class PriorityQueue { public: int size; int buffer[MAX + 1]; PriorityQueue() { size = 0; } void insert(int x) { size++; buffer[size] = x; upHeap(size); } int get() { int v = buffer[1]; ...
replace
6
7
6
7
0