buggy_code stringlengths 11 625k | fixed_code stringlengths 17 625k | bug_type stringlengths 2 4.45k | language int64 0 8 | token_count int64 5 200k | change_count int64 0 100 |
|---|---|---|---|---|---|
//============================================================================
// Name : one.cpp
// Author : Lich_Ning
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#incl... | //============================================================================
// Name : one.cpp
// Author : Lich_Ning
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#incl... | [["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]] | 1 | 1,033 | 4 |
#include <iostream>
#include <stdio.h>
using namespace std;
struct Node {
int key;
Node *parent;
Node *left;
Node *right;
};
struct Node *NIL, *root;
void init() { root = NIL; }
void insert(Node *z) {
struct Node *y = NIL; // xの親
struct Node *x = root;
while (x != NIL) {
y = x;
if (z->key < x... | #include <iostream>
#include <stdio.h>
using namespace std;
struct Node {
int key;
Node *parent;
Node *left;
Node *right;
};
struct Node *NIL, *root;
void init() { root = NIL; }
void insert(Node *z) {
struct Node *y = NIL; // xの親
struct Node *x = root;
while (x != NIL) {
y = x;
if (z->key < x... | [["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]] | 1 | 537 | 2 |
#include <cstdio>
#include <iostream>
#include <memory>
using namespace std;
struct Node {
int key;
Node *parent;
Node *left;
Node *right;
Node(int key = -1)
: key(key), parent(nullptr), left(nullptr), right(nullptr){};
};
struct Tree {
Node *root;
Tree() : root(nullptr){};
};
static void inse... | #include <cstdio>
#include <iostream>
#include <memory>
using namespace std;
struct Node {
int key;
Node *parent;
Node *left;
Node *right;
Node(int key = -1)
: key(key), parent(nullptr), left(nullptr), right(nullptr){};
};
struct Tree {
Node *root;
Tree() : root(nullptr){};
};
static void inse... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]] | 1 | 560 | 2 |
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
struct Node {
int key;
Node *right;
Node *left;
Node *parent;
};
Node *root;
Node *NIL;
Node *find(Node *u, int k) {
while (u != NIL && k != u->key) {
if (k < u->key) {
u = u->left;
} else {
u = u->right;
... | #include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
struct Node {
int key;
Node *right;
Node *left;
Node *parent;
};
Node *root;
Node *NIL;
Node *find(Node *u, int k) {
while (u != NIL && k != u->key) {
if (k < u->key) {
u = u->left;
} else {
u = u->right;
... | [["+", 0, 57, 64, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22], ["+", 75, 76, 0, 57, 64, 9, 0, 1, 0, 35]] | 1 | 461 | 4 |
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
struct Node {
int key;
Node *right, *left, *parent;
};
Node *root, *NIL;
Node *find(Node *u, int k) {
while (u != NIL && k != u->key) {
if (k < u->key) {
u = u->left;
} else
u = u->right;
}
... | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
struct Node {
int key;
Node *right, *left, *parent;
};
Node *root, *NIL;
Node *find(Node *u, int k) {
while (u != NIL && k != u->key) {
if (k < u->key) {
u = u->left;
} else
u = u->right;
}
... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 483 | 4 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
private static FastScanner sc = new FastScanner();
static StringBuilder ans = new StringBuilder();
public static void main(String[] args) {
int n = sc.nextInt();... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
private static FastScanner sc = new FastScanner();
static StringBuilder ans = new StringBuilder();
public static void main(String[] args) {
int n = sc.nextInt();... | [["-", 0, 1, 0, 11, 31, 509, 500, 504, 71, 22], ["+", 0, 1, 0, 11, 31, 509, 500, 504, 71, 22], ["-", 0, 1, 0, 11, 12, 509, 500, 504, 71, 22], ["+", 0, 1, 0, 11, 12, 509, 500, 504, 71, 22]] | 3 | 1,585 | 4 |
#include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL) {
x = x->left;
}
return x;
}
Node treeMaximum(Node x) {
while (x... | #include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL) {
x = x->left;
}
return x;
}
Node treeMaximum(Node x) {
while (x... | [["-", 8, 9, 0, 57, 64, 37, 0, 2, 63, 22], ["+", 8, 9, 0, 57, 64, 37, 0, 2, 63, 22]] | 0 | 778 | 2 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define UND_NODE -1
#define UND_HEIGHT -1
#define MAX_CMD_LENGTH 10
typedef struct {
// int id;
int right;
int left;
int parent;
int height;
} BinaryNode;
int nodeDepthFromId(BinaryNode nodes[], int length, int id) {
int i = 0;
while (nodes... |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define UND_NODE -1
#define UND_HEIGHT -1
#define MAX_CMD_LENGTH 10
typedef struct {
// int id;
int right;
int left;
int parent;
int height;
} BinaryNode;
int nodeDepthFromId(BinaryNode nodes[], int length, int id) {
int i = 0;
while (nodes... | [["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 0 | 1,386 | 5 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct d {
struct d *parent;
struct d *left;
struct d *right;
int key;
} node;
typedef node *Node;
Node root;
void insert(int key) {
Node x = root;
Node y = NULL;
Node z;
z = (Node)malloc(sizeof(node));
z->key = key;
z->left = NU... | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct d {
struct d *parent;
struct d *left;
struct d *right;
int key;
} node;
typedef node *Node;
Node root;
void insert(int key) {
Node x = root;
Node y = NULL;
Node z;
z = (Node)malloc(sizeof(node));
z->key = key;
z->left = NU... | [["+", 75, 76, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 75, 76, 0, 57, 64, 9, 0, 37, 0, 35]] | 0 | 864 | 2 |
#include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL) {
x = x->left;
}
if (x->parent->left == x) {
x->parent->left = x-... | #include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL) {
x = x->left;
}
if (x->parent->left == x) {
x->parent->left = x-... | [["-", 0, 11, 12, 2, 3, 4, 0, 118, 28, 22], ["+", 0, 11, 12, 2, 3, 4, 0, 118, 28, 22]] | 0 | 1,000 | 2 |
#include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL)
x = x->left;
return x;
}
Node treeMaximum(Node x) {
while (x->right ... | #include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL)
x = x->left;
return x;
}
Node treeMaximum(Node x) {
while (x->right ... | [["-", 64, 9, 0, 1, 0, 11, 31, 118, 28, 22], ["+", 64, 9, 0, 1, 0, 11, 31, 118, 28, 22]] | 0 | 812 | 2 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NIL NULL
struct node {
int key;
struct node *right;
struct node *left;
struct node *parent;
};
struct node *root;
struct node *find(int);
void inOrder(struct node *);
void preOrder(struct node *);
void insert(int);
void delete (struct node *... | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NIL NULL
struct node {
int key;
struct node *right;
struct node *left;
struct node *parent;
};
struct node *root;
struct node *find(int);
void inOrder(struct node *);
void preOrder(struct node *);
void insert(int);
void delete (struct node *... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]] | 0 | 901 | 2 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NIL NULL
typedef struct node *Node;
struct node {
Node right;
Node left;
Node parent;
int key;
};
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL)
x = x->left;
return x;
}
Node treeSearch(Node x, int k) {
while (x != NIL &... | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NIL NULL
typedef struct node *Node;
struct node {
Node right;
Node left;
Node parent;
int key;
};
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL)
x = x->left;
return x;
}
Node treeSearch(Node x, int k) {
while (x != NIL &... | [["-", 0, 91, 28, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 91, 28, 2, 3, 4, 0, 5, 0, 6]] | 0 | 731 | 2 |
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
Node root;
void treeinsert(int k) {
Node y = NIL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->left =... | #include <stdio.h>
#include <stdlib.h>
#define NIL NULL
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
Node root;
void treeinsert(int k) {
Node y = NIL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->left =... | [["-", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["-", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46]] | 0 | 751 | 2 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Node {
int key;
struct Node *right, *left, *parent;
};
struct Node *root, *NIL;
struct Node *treeMinimum(struct Node *x) {
while (x->left != NIL)
x = x->left;
return x;
}
struct Node *find(struct Node *u, int k) {
while (u != NIL && k !... | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Node {
int key;
struct Node *right, *left, *parent;
};
struct Node *root, *NIL;
struct Node *treeMinimum(struct Node *x) {
while (x->left != NIL)
x = x->left;
return x;
}
struct Node *find(struct Node *u, int k) {
while (u != NIL && k !... | [["+", 75, 76, 0, 57, 15, 23, 0, 16, 17, 60], ["+", 75, 76, 0, 57, 15, 23, 0, 16, 12, 13]] | 0 | 794 | 2 |
#include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
#define TRUE 1
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL) {
x = x->left;
}
return x;
}
void insert(int k) {
N... | #include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
#define TRUE 1
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL) {
x = x->left;
}
return x;
}
void insert(int k) {
N... | [["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 21], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 21], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22]] | 0 | 738 | 4 |
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
struct node {
struct node *right, *left, *parent;
int key;
};
typedef struct node *Node;
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL)
x = x->left;
return x;
}
Node treeSuccessor(Node x) {
if (x->right != NIL)
return treeMinimum(x-... | #include <stdio.h>
#include <stdlib.h>
#define NIL NULL
struct node {
struct node *right, *left, *parent;
int key;
};
typedef struct node *Node;
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL)
x = x->left;
return x;
}
Node treeSuccessor(Node x) {
if (x->right != NIL)
return treeMinimum(x-... | [["-", 15, 23, 0, 16, 12, 16, 31, 118, 28, 22], ["+", 15, 23, 0, 16, 12, 16, 31, 118, 28, 22]] | 0 | 755 | 2 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* ------------------------------ Node ------------------------------ */
typedef struct Node {
int key;
struct Node *parent, *left, *right;
} Node;
Node *root = NULL;
Node *deletedRoot = NULL;
void delete (Node *);
/* ------------------------------ Crea... | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* ------------------------------ Node ------------------------------ */
typedef struct Node {
int key;
struct Node *parent, *left, *right;
} Node;
Node *root = NULL;
Node *deletedRoot = NULL;
void delete (Node *);
/* ------------------------------ Crea... | [["-", 0, 1, 0, 11, 31, 118, 28, 118, 119, 120], ["+", 0, 1, 0, 11, 31, 118, 28, 118, 119, 120]] | 0 | 964 | 2 |
#include <stdio.h>
#include <stdlib.h>
typedef struct _node {
struct _node *left, *right;
int key;
} node;
node *root = NULL;
node *deleteMin(node **p) {
node *x;
while ((*p)->left != NULL)
p = &(*p)->left;
x = *p;
*p = NULL;
return x;
}
void delete (node **p) {
node *x, *y;
x = *p;
if (... | #include <stdio.h>
#include <stdlib.h>
typedef struct _node {
struct _node *left, *right;
int key;
} node;
node *root = NULL;
node *deleteMin(node **p) {
node *x;
while ((*p)->left != NULL)
p = &(*p)->left;
x = *p;
*p = NULL;
return x;
}
void delete (node **p) {
node *x, *y;
x = *p;
if (... | [["+", 0, 1, 0, 41, 15, 16, 31, 66, 17, 48], ["+", 0, 41, 15, 16, 31, 66, 28, 23, 0, 24], ["+", 31, 66, 28, 23, 0, 2, 3, 4, 0, 25]] | 0 | 697 | 3 |
#include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right; /* ????????? */
struct node *left; /* ????????? */
struct node *parent; /* ??? */
int key; /* ??????????????? */
};
typedef struct node *Node;
#define NIL NULL
Node root = NIL;
Node treeMinimum(Node x) {
while (x->left ... | #include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right; /* ????????? */
struct node *left; /* ????????? */
struct node *parent; /* ??? */
long key; /* ??????????????? */
};
typedef struct node *Node;
#define NIL NULL
Node root = NIL;
Node treeMinimum(Node x) {
while (x->left ... | [["-", 0, 30, 0, 122, 8, 123, 0, 124, 39, 40], ["+", 0, 122, 8, 123, 0, 124, 39, 86, 0, 96], ["-", 64, 9, 0, 1, 0, 11, 31, 118, 28, 22], ["+", 64, 9, 0, 1, 0, 11, 31, 118, 28, 22]] | 0 | 774 | 4 |
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
struct node {
struct node *left;
struct node *right;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL) {
x = x->left;
}
return x;
}
Node tr... | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
struct node {
struct node *left;
struct node *right;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL) {
x = x->left;
}
return x;
}
Node tr... | [["-", 64, 9, 0, 1, 0, 11, 12, 118, 119, 120], ["+", 64, 9, 0, 1, 0, 11, 12, 118, 119, 120]] | 0 | 897 | 2 |
#include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
int flag;
Node treeMinimum(Node x) {
while (x->left != NIL)
x = x->left;
return x;
}
Node treeSuccessor(Node x) {
Node... | #include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
int flag;
Node treeMinimum(Node x) {
while (x->left != NIL)
x = x->left;
return x;
}
Node treeSuccessor(Node x) {
Node... | [["-", 64, 9, 0, 1, 0, 11, 31, 118, 28, 22], ["+", 64, 9, 0, 1, 0, 11, 31, 118, 28, 22]] | 0 | 759 | 2 |
#include <stdio.h>
#include <stdlib.h>
struct node {
struct node *l;
struct node *r;
struct node *p;
int key;
};
typedef struct node *Node;
void inorder(Node);
void preorder(Node);
void insert(int);
char *find(int);
void delete (int);
Node successor(Node);
Node minimum(Node);
Node root;
int main(void) {
... | #include <stdio.h>
#include <stdlib.h>
struct node {
struct node *l;
struct node *r;
struct node *p;
int key;
};
typedef struct node *Node;
void inorder(Node);
void preorder(Node);
void insert(int);
char *find(int);
void delete (int);
Node successor(Node);
Node minimum(Node);
Node root;
int main(void) {
... | [["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 98], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 106]] | 0 | 837 | 2 |
#include <stdio.h>
#include <stdlib.h>
struct node {
struct node *left;
struct node *right;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL) {
x = x->left;
}
}
Node treeSearch(Node u, int k) {
if (u == NIL) {
... | #include <stdio.h>
#include <stdlib.h>
struct node {
struct node *left;
struct node *right;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL) {
x = x->left;
}
return x;
}
Node treeSearch(Node u, int k) {
if (u... | [["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35]] | 0 | 758 | 3 |
#include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL)
x = x->left;
return x;
}
Node treeSearch(Node u, int k) {
if (u == N... | #include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL)
x = x->left;
return x;
}
Node treeSearch(Node u, int k) {
if (u == N... | [["-", 8, 9, 0, 57, 64, 1, 0, 16, 17, 60], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 17, 32]] | 0 | 755 | 4 |
/*
???????????????????????????????????????¢??I
???????????????????\??????????????±??????????????????????I
*/
#define VERNIY \
st(); \
int ver = 0, niy = 0, hbk = 0
#includ... | /*
???????????????????????????????????????¢??I
???????????????????\??????????????±??????????????????????I
*/
#define VERNIY \
st(); \
int ver = 0, niy = 0, hbk = 0
#includ... | [["+", 0, 9, 0, 1, 0, 11, 31, 118, 17, 143], ["+", 0, 9, 0, 1, 0, 11, 31, 118, 119, 120]] | 1 | 1,478 | 2 |
#include <iostream>
using namespace std;
struct Node {
int key;
Node *left, *right, *parent;
};
Node *root, *NIL;
Node *find(Node *u, int k) {
while (u != NIL && k != u->key) {
if (k < u->key) {
u = u->left;
} else {
u = u->right;
}
}
return u;
}
Node *getMinimum(Node *u) {
whi... | #include <iostream>
using namespace std;
struct Node {
int key;
Node *left, *right, *parent;
};
Node *root, *NIL;
Node *find(Node *u, int k) {
while (u != NIL && k != u->key) {
if (k < u->key) {
u = u->left;
} else {
u = u->right;
}
}
return u;
}
Node *getMinimum(Node *u) {
whi... | [["-", 64, 9, 0, 1, 0, 11, 31, 118, 119, 120], ["+", 64, 9, 0, 1, 0, 11, 31, 118, 119, 120]] | 1 | 733 | 2 |
#include <iostream>
#include <stdio.h>
#include <string.h>
#define MAX 100
//#define NIL -1
struct Node {
int key;
Node *parent, *left, *right;
};
Node *root, *NIL;
int n;
void insert(int val) {
Node *y = NIL;
Node *x = root;
Node *z = new Node();
z->key = val;
z->left = NIL;
z->right = NIL;
whi... | #include <iostream>
#include <stdio.h>
#include <string.h>
#define MAX 100
//#define NIL -1
struct Node {
int key;
Node *parent, *left, *right;
};
Node *root, *NIL;
int n;
void insert(int val) {
Node *y = NIL;
Node *x = root;
Node *z = new Node();
z->key = val;
z->left = NIL;
z->right = NIL;
whi... | [["+", 0, 11, 12, 2, 3, 4, 0, 118, 17, 143], ["+", 0, 11, 12, 2, 3, 4, 0, 118, 119, 120], ["+", 0, 14, 8, 9, 0, 1, 0, 363, 0, 364], ["+", 0, 14, 8, 9, 0, 1, 0, 363, 0, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 711 | 5 |
#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... | [["+", 0, 52, 15, 339, 51, 16, 31, 118, 17, 143], ["+", 0, 52, 15, 339, 51, 16, 31, 118, 119, 120]] | 1 | 745 | 2 |
// 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... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]] | 1 | 647 | 2 |
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
struct Node {
int key;
Node *parent, *left, *right;
};
Node *root, *NIL;
Node *treeMinimum(Node *x) {
while (x->left != NIL)
x = x->left;
return x;
}
Node *find(Node *u, int k) {
while (u != NIL && k != u->... | #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
struct Node {
int key;
Node *parent, *left, *right;
};
Node *root, *NIL;
Node *treeMinimum(Node *x) {
while (x->left != NIL)
x = x->left;
return x;
}
Node *find(Node *u, int k) {
while (u != NIL && k != u->... | [["-", 64, 37, 0, 2, 3, 4, 0, 118, 119, 120], ["+", 64, 37, 0, 2, 3, 4, 0, 118, 119, 120], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 716 | 4 |
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
struct node {
int num;
node *parent, *left, *right;
};
node *root, *NIL;
node *nextnode(node *x) {
node *z = x->left;
while (z->right != NIL) {
z = z->right;
}
return z;
}
void denode(node *z) {
node *... | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
struct node {
int num;
node *parent, *left, *right;
};
node *root, *NIL;
node *nextnode(node *x) {
node *z = x->right;
while (z->left != NIL) {
z = z->left;
}
return z;
}
void denode(node *z) {
node *x... | [["-", 8, 9, 0, 43, 49, 50, 51, 118, 119, 120], ["+", 8, 9, 0, 43, 49, 50, 51, 118, 119, 120], ["-", 0, 52, 15, 339, 51, 16, 31, 118, 119, 120], ["+", 0, 52, 15, 339, 51, 16, 31, 118, 119, 120], ["-", 8, 9, 0, 1, 0, 11, 12, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 11, 12, 118, 119, 120]] | 1 | 651 | 6 |
#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 ... | [["-", 0, 14, 8, 9, 0, 1, 0, 363, 0, 364], ["-", 0, 14, 8, 9, 0, 1, 0, 363, 0, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 57, 64, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 1, 0, 363, 0, 364], ["+", 0, 14, 8, 9, 0, 1, 0, 363, 0, 22]] | 1 | 762 | 6 |
/*
二つの子がいる節点をdeleteするときは、
「左の部分木の中で最大のkeyをもつ節点(左の部分木の中で一番右下)」 もしくは、
「右の部分木の中で最少のkeyをもつ節点(右の部分木の中で一番左下)」
の節点が、消した位置に来るようにすればよい。
今回は小難しい節点の入れ替えの処理をしなくても
キーだけ変えて、左下or右下 の節点を消しておけばよい。
*/
/*
キーの重複がないそうなので、
配列の添え字をそのままキーにするのが最速っぽい。
(vectorは添え字の指定ができないからダメ、キーがzの時 left[z]、right[z]みたいに使えるのが最速
)
でも重複に備えるorキーがデカいなら、上のやり方は使えない... | /*
二つの子がいる節点をdeleteするときは、
「左の部分木の中で最大のkeyをもつ節点(左の部分木の中で一番右下)」 もしくは、
「右の部分木の中で最少のkeyをもつ節点(右の部分木の中で一番左下)」
の節点が、消した位置に来るようにすればよい。
今回は小難しい節点の入れ替えの処理をしなくても
キーだけ変えて、左下or右下 の節点を消しておけばよい。
*/
/*
キーの重複がないそうなので、
配列の添え字をそのままキーにするのが最速っぽい。
(vectorは添え字の指定ができないからダメ、キーがzの時 left[z]、right[z]みたいに使えるのが最速
)
でも重複に備えるorキーがデカいなら、上のやり方は使えない... | [["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 79]] | 1 | 813 | 2 |
CMD=0
VAL=1
class Node
attr_accessor :value,:left,:right,:parent
def initialize (value,parent)
@value = value
@parent = parent
@left = nil
@right = nil
end
def insert (value)
if value < @value
if @left.nil?
@left = Node.new(value,self)
else
@left.insert(value)
... | CMD=0
VAL=1
class Node
attr_accessor :value,:left,:right,:parent
def initialize (value,parent)
@value = value
@parent = parent
@left = nil
@right = nil
end
def insert (value)
if value < @value
if @left.nil?
@left = Node.new(value,self)
else
@left.insert(value)
... | [["+", 0, 121, 75, 95, 0, 662, 12, 652, 486, 777], ["+", 0, 121, 75, 95, 0, 662, 12, 652, 17, 131]] | 4 | 474 | 14 |
class BinarySearchTree
class Node
attr_reader :key
attr_accessor :parent, :left, :right
def initialize(key, parent)
@key = key
@parent = parent
end
end
def insert(key)
parent = nil
current = @root
while current
parent = current
if key < current.key
cur... | class BinarySearchTree
class Node
attr_reader :key
attr_accessor :parent, :left, :right
def initialize(key, parent)
@key = key
@parent = parent
end
end
def insert(key)
parent = nil
current = @root
while current
parent = current
if key < current.key
cur... | [["-", 0, 735, 8, 736, 0, 662, 12, 762, 0, 21], ["+", 0, 735, 8, 736, 0, 662, 12, 652, 17, 131]] | 4 | 589 | 2 |
class Node:
def __init__(self, key):
self.key = key
self.parent = None
self.left = None
self.right = None
class Tree:
def __init__(self):
self.root = None
self.inorder = []
self.preorder = []
def insert(self, node):
p = None
x = self.... | class Node:
def __init__(self, key):
self.key = key
self.parent = None
self.left = None
self.right = None
class Tree:
def __init__(self):
self.root = None
self.inorder = []
self.preorder = []
def insert(self, node):
p = None
x = self.... | [["-", 8, 196, 0, 57, 15, 666, 0, 319, 0, 131], ["-", 8, 196, 0, 57, 15, 666, 0, 319, 319, 22], ["+", 0, 37, 0, 652, 3, 4, 0, 319, 0, 131], ["+", 0, 37, 0, 652, 3, 4, 0, 319, 319, 22]] | 5 | 782 | 6 |
from sys import stdin
class Node:
def __init__(self, id):
self.id = id
self.left = None
self.right = None
self.parent = None
def preorder_tree_walk(root):
print('', root.id, end='')
if root.left != None:
preorder_tree_walk(root.left)
if root.right != None:
... |
from sys import stdin
class Node:
def __init__(self, id):
self.id = id
self.left = None
self.right = None
self.parent = None
def preorder_tree_walk(root):
print('', root.id, end='')
if root.left != None:
preorder_tree_walk(root.left)
if root.right != None:
... | [["-", 36, 36, 36, 36, 0, 656, 0, 14, 141, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 14, 141, 22]] | 5 | 584 | 2 |
class BinarySearchTree:
root = None
def insert(self, k):
y = None
x = self.root
z = Node(k)
while x:
y = x
if z.k < x.k:
x = x.l
else:
x = x.r
z.p = y
if y == None:
self.root... | class BinarySearchTree:
root = None
def insert(self, k):
y = None
x = self.root
z = Node(k)
while x:
y = x
if z.k < x.k:
x = x.l
else:
x = x.r
z.p = y
if y == None:
self.root... | [["-", 0, 57, 15, 679, 12, 666, 0, 319, 500, 22], ["+", 0, 57, 15, 679, 12, 666, 0, 319, 500, 22]] | 5 | 646 | 2 |
class node:
def __init__(self,key=None):
self.left=None
self.right=None
self.parent=None
self.key=key
def insert(T,z):
x=T
y=None
while isinstance(x,node):
y=x
if z.key<x.key:
x=x.left
else:
x=x.right
z.parent=y
if ... | class node:
def __init__(self,key=None):
self.left=None
self.right=None
self.parent=None
self.key=key
def insert(T,z):
x=T
y=None
while isinstance(x,node):
y=x
if z.key<x.key:
x=x.left
else:
x=x.right
z.parent=y
if ... | [["+", 0, 662, 12, 652, 3, 4, 0, 319, 0, 131], ["+", 0, 662, 12, 652, 3, 4, 0, 319, 319, 22]] | 5 | 734 | 2 |
import sys
class Node:
def __init__(self, x, parent=None):
self.key = x
self.left = None
self.right = None
self.parent = parent
def append_child(self, child):
if self.key > child.key:
self.left = child
child.parent = self
elif self.key < ... | import sys
class Node:
def __init__(self, x, parent=None):
self.key = x
self.left = None
self.right = None
self.parent = parent
def append_child(self, child):
if self.key > child.key:
self.left = child
child.parent = self
elif self.key < ... | [["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 727 | 1 |
class Node(object):
root = None
def __init__(self, key, parent=None, left=None, right=None):
self.key = key
self.parent = parent
self.left = left
self.right = right
self.height = None
@classmethod
def insert(cls, z):
y = None
x = cls.root
... | class Node(object):
root = None
def __init__(self, key, parent=None, left=None, right=None):
self.key = key
self.parent = parent
self.left = left
self.right = right
self.height = None
@classmethod
def insert(cls, z):
y = None
x = cls.root
... | [["-", 64, 196, 0, 37, 0, 652, 63, 319, 500, 22], ["+", 64, 196, 0, 37, 0, 652, 63, 319, 500, 22]] | 5 | 1,008 | 2 |
#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->right... | #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->right... | [["-", 0, 1, 0, 2, 3, 4, 0, 118, 119, 120], ["+", 0, 1, 0, 2, 3, 4, 0, 118, 119, 120]] | 1 | 754 | 4 |
#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->right =... | #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->right =... | [["-", 75, 76, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 75, 76, 0, 1, 0, 11, 12, 2, 63, 22]] | 1 | 711 | 2 |
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define INTINF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
struct Node {
int key;
Node *parent, *left, *right;
... | #include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define INTINF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
struct Node {
int key;
Node *parent, *left, *right;
... | [["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]] | 1 | 851 | 2 |
#include <iostream>
#include <stdio.h>
#include <string>
#define MAX 500000
struct node {
int key;
int parent, left, right;
} T[MAX];
int root;
void PrePrint(int t) {
if (t == -1)
return;
printf(" %d", T[t].key);
PrePrint(T[t].left);
PrePrint(T[t].right);
}
void InPrint(int t) {
if (t == -1)
r... | #include <iostream>
#include <stdio.h>
#include <string>
#define MAX 500000
struct node {
int key;
int parent, left, right;
} T[MAX];
int root;
void PrePrint(int t) {
if (t == -1)
return;
printf(" %d", T[t].key);
PrePrint(T[t].left);
PrePrint(T[t].right);
}
void InPrint(int t) {
if (t == -1)
r... | [["+", 0, 2, 3, 4, 0, 118, 28, 69, 28, 22], ["+", 3, 4, 0, 118, 28, 69, 341, 342, 0, 70], ["+", 3, 4, 0, 118, 28, 69, 341, 342, 0, 73], ["+", 0, 37, 0, 2, 3, 4, 0, 118, 17, 131], ["+", 0, 37, 0, 2, 3, 4, 0, 118, 119, 120]] | 1 | 1,005 | 5 |
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
struct node {
int key;
node *lc, *rc, *p;
};
node *root = 0;
void insert(int x) {
node *pre = root; //设当前节点为根,以根为起点
node *temp = pre; //用来保存当前节点的临时指针
node *in = (node *)malloc(sizeof(node));
in->key = x;
in->lc = 0;
in->rc... | #include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
struct node {
int key;
node *lc, *rc, *p;
};
node *root = 0;
void insert(int x) {
node *pre = root; //设当前节点为根,以根为起点
node *temp = pre; //用来保存当前节点的临时指针
node *in = (node *)malloc(sizeof(node));
in->key = x;
in->lc = 0;
in->rc... | [["-", 75, 76, 0, 9, 0, 57, 75, 76, 0, 95], ["-", 0, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["-", 0, 9, 0, 57, 75, 76, 0, 9, 0, 46]] | 1 | 761 | 3 |
#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 ... | [["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 684 | 2 |
#include <cstdio>
#include <vector>
using namespace std;
struct node {
int key;
int parent, left, right;
node() {
parent = -1;
left = -1;
right = -1;
}
};
vector<node> tree;
int root = -1;
void print_pre(int id) {
if (id == -1) {
return;
}
printf(" %d", tree[id].key);
print_pre(tree[... | #include <cstdio>
#include <vector>
using namespace std;
struct node {
int key;
int parent, left, right;
node() {
parent = -1;
left = -1;
right = -1;
}
};
vector<node> tree;
int root = -1;
void print_pre(int id) {
if (id == -1) {
return;
}
printf(" %d", tree[id].key);
print_pre(tree[... | [["-", 0, 43, 49, 50, 51, 218, 369, 370, 0, 22], ["+", 51, 218, 49, 185, 54, 55, 0, 56, 39, 40], ["+", 51, 218, 49, 185, 54, 55, 0, 56, 49, 22], ["+", 31, 66, 28, 23, 0, 2, 3, 4, 0, 22]] | 1 | 904 | 6 |
#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... | [["-", 0, 1, 0, 11, 12, 118, 28, 118, 28, 22], ["+", 0, 1, 0, 11, 12, 118, 28, 118, 28, 22]] | 1 | 1,061 | 2 |
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
struct Node {
int key;
Node *parent, *left, *right;
};
void insert(int key);
Node *find(Node *x, int key);
void inorder(Node *u);
void preorder(Node *u);
void deleteNode(int key);
Node *getSuccessor(Node *z);
Node *getMinimum(Node *z);
... | #include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
struct Node {
int key;
Node *parent, *left, *right;
};
void insert(int key);
Node *find(Node *x, int key);
void inorder(Node *u);
void preorder(Node *u);
void deleteNode(int key);
Node *getSuccessor(Node *z);
Node *getMinimum(Node *z);
... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60]] | 1 | 788 | 4 |
#include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x) {}
Node treeMaximum(Node x) {}
Node treeSearch(Node u, int k) {
Node x = u;
while (x != NIL) {
... | #include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x) {}
Node treeMaximum(Node x) {}
Node treeSearch(Node u, int k) {
Node x = u;
while (x != NIL) {
... | [["+", 0, 11, 12, 2, 3, 4, 0, 118, 17, 143], ["+", 0, 11, 12, 2, 3, 4, 0, 118, 119, 120]] | 1 | 787 | 2 |
#include <cstdio>
#include <queue>
#define NIL (-1)
using namespace std;
struct node {
int parent;
int left;
int right;
int key;
};
node tree[500001];
int treesize;
int root = NIL;
void pre(int id) {
if (id == -1)
return;
printf(" %d", tree[id].key);
if (tree[id].left >= 0)
pre(tree[id].left);... | #include <cstdio>
#include <queue>
#define NIL (-1)
using namespace std;
struct node {
int parent;
int left;
int right;
int key;
};
node tree[500001];
int treesize;
int root = NIL;
void pre(int id) {
if (id == -1)
return;
printf(" %d", tree[id].key);
if (tree[id].left >= 0)
pre(tree[id].left);... | [["-", 8, 9, 0, 43, 49, 50, 51, 118, 119, 120], ["+", 8, 9, 0, 43, 49, 50, 51, 118, 119, 120], ["-", 0, 52, 15, 339, 51, 16, 31, 118, 119, 120], ["+", 0, 52, 15, 339, 51, 16, 31, 118, 119, 120], ["-", 0, 52, 8, 1, 0, 11, 12, 118, 119, 120], ["+", 0, 52, 8, 1, 0, 11, 12, 118, 119, 120]] | 1 | 910 | 6 |
#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... | [["-", 0, 57, 64, 1, 0, 11, 12, 118, 28, 22], ["+", 0, 57, 64, 1, 0, 11, 12, 118, 28, 22]] | 1 | 756 | 2 |
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
struct Node {
int key;
Node *p, *l, *r;
};
Node *root, *NIL;
void insert(int k) {
Node *x = root;
Node *y = NIL;
Node *z;
z = (Node *)malloc(sizeof(Node));
z->key = k;
z->l = NIL;
z->r = NIL;
while ... | #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
struct Node {
int key;
Node *p, *l, *r;
};
Node *root, *NIL;
void insert(int k) {
Node *x = root;
Node *y = NIL;
Node *z;
z = (Node *)malloc(sizeof(Node));
z->key = k;
z->l = NIL;
z->r = NIL;
while ... | [["+", 0, 37, 0, 2, 3, 4, 0, 118, 17, 143], ["+", 0, 37, 0, 2, 3, 4, 0, 118, 119, 120]] | 1 | 770 | 2 |
#include <stdio.h>
#define MAX 250
int main() {
int n, i;
int A[MAX];
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &A[i]);
}
for (i = 0; i <= n; i++) {
printf("node %d: key = %d, ", i + 1, A[i]);
if (i != 1)
printf("parent key = %d, ", A[i / 2]);
if (i * 2 <= n)
print... | #include <stdio.h>
#define MAX 250
int main() {
int n, i;
int A[MAX];
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &A[i]);
}
for (i = 1; i <= n; i++) {
printf("node %d: key = %d, ", i, A[i]);
if (i != 1)
printf("parent key = %d, ", A[i / 2]);
if (i * 2 <= n)
printf("... | [["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 0 | 169 | 8 |
#include <stdio.h>
#define Max 10001
int parent(int);
int left(int);
int right(int);
int main() {
int heap, i, A[Max];
scanf("%d", &heap);
for (i = 1; i <= heap; i++)
scanf("%d", &A[i]);
for (i = 1; i <= heap; i++) {
printf("node: %d: key = %d,", i, A[i]);
if (parent(i) >= 1)
printf("parent ke... | #include <stdio.h>
#define Max 10001
int parent(int);
int left(int);
int right(int);
int main() {
int heap, i, A[Max];
scanf("%d", &heap);
for (i = 1; i <= heap; i++)
scanf("%d", &A[i]);
for (i = 1; i <= heap; i++) {
printf("node %d: key = %d, ", i, A[i]);
if (parent(i) >= 1)
printf("parent ke... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 0 | 227 | 2 |
#include <stdio.h>
#define MAX 250
int main() {
int key[MAX];
int i, n;
scanf("%d", &n);
for (i = 1; i <= n; i++)
scanf("%d", &key[i]);
for (i = 1; i <= n; i++) {
printf("node %d:", i);
printf("key = %d, ", key[i]);
if (((i) / 2) > 0)
printf("parent key = %d, ", key[(i) / 2]);
if... | #include <stdio.h>
#define MAX 250
int main() {
int key[MAX];
int i, n;
scanf("%d", &n);
for (i = 1; i <= n; i++)
scanf("%d", &key[i]);
for (i = 1; i <= n; i++) {
printf("node %d: ", i);
printf("key = %d, ", key[i]);
if (((i) / 2) > 0)
printf("parent key = %d, ", key[(i) / 2]);
i... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 0 | 192 | 2 |
#include <stdio.h>
#define N 255
#define NIL -1
typedef struct {
int key;
int right, left, parent;
} Node;
Node T[N];
int A[N];
int n;
void makeTree(Node *, int *);
void print(Node *);
int main() {
int i;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &A[i]);
}
makeTree(T, A);
prin... | #include <stdio.h>
#define N 255
#define NIL -2000001
typedef struct {
int key;
int right, left, parent;
} Node;
Node T[N];
int A[N];
int n;
void makeTree(Node *, int *);
void print(Node *);
int main() {
int i;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &A[i]);
}
makeTree(T, A);
... | [["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]] | 0 | 437 | 2 |
#include <stdio.h>
#define MAX 250
#define NIL -1
struct Node {
int p;
int l;
int r;
};
struct Node A[MAX];
int n, T[MAX];
int main() {
int i, x;
scanf("%d", &n);
for (i = 0; i < n; i++) {
A[i].p = NIL;
A[i].l = NIL;
A[i].r = NIL;
}
for (i = 0; i < n; i++) {
scanf("%d", &T[i]);
if (... | #include <stdio.h>
#define MAX 251
#define NIL -100
struct Node {
int p;
int l;
int r;
};
struct Node A[MAX];
int n, T[MAX];
int main() {
int i, x;
scanf("%d", &n);
for (i = 0; i < n; i++) {
A[i].p = NIL;
A[i].l = NIL;
A[i].r = NIL;
}
for (i = 0; i < n; i++) {
scanf("%d", &T[i]);
if... | [["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]] | 0 | 361 | 4 |
#include <stdio.h>
int parent(int);
int left(int);
int right(int);
int main() {
int i, a, A[251];
scanf("%d", &a);
for (i = 1; i <= a; i++) {
scanf("%d", &A[i]);
}
for (i = 1; i <= a; i++) {
printf("node %d, key = %d, ", i, A[i]);
if (parent(i) >= 1) {
printf("parent key = %d, ", A[parent(i... | #include <stdio.h>
int parent(int);
int left(int);
int right(int);
int main() {
int i, a, A[251];
scanf("%d", &a);
for (i = 1; i <= a; i++) {
scanf("%d", &A[i]);
}
for (i = 1; i <= a; i++) {
printf("node %d: key = %d, ", i, A[i]);
if (parent(i) >= 1) {
printf("parent key = %d, ", A[parent(i... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 0 | 234 | 2 |
#include <stdio.h>
#define H 2000000
int main() {
int id, A[H], x;
scanf("%d", &x);
for (id = 1; id <= x; id++) {
scanf("%d", &A[id]);
}
for (id = 1; id <= x; id++) {
printf("node %d: key = %d ", id, A[id]);
if (id / 2 >= 1)
printf("parent key = %d, ", A[id / 2]);
if (id * 2 <= x)
... | #include <stdio.h>
#define H 2000000
int main() {
int id, A[H], x;
scanf("%d", &x);
for (id = 1; id <= x; id++) {
scanf("%d", &A[id]);
}
for (id = 1; id <= x; id++) {
printf("node %d: key = %d, ", id, A[id]);
if (id / 2 >= 1)
printf("parent key = %d, ", A[id / 2]);
if (id * 2 <= x)
... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 0 | 168 | 4 |
#include <stdio.h>
#include <stdlib.h>
#define NIL -1
typedef struct Node {
int key, parent, left, right;
} Node;
int n;
Node *tree;
Node *initNodeWith(int key) {
Node *node = (Node *)malloc(sizeof(Node));
node->key = key;
node->parent = NIL;
node->left = NIL;
node->right = NIL;
return node;
}
void ... | #include <stdio.h>
#include <stdlib.h>
#define NIL -1
typedef struct Node {
int key, parent, left, right;
} Node;
int n;
Node *tree;
Node *initNodeWith(int key) {
Node *node = (Node *)malloc(sizeof(Node));
node->key = key;
node->parent = NIL;
node->left = NIL;
node->right = NIL;
return node;
}
void ... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 0 | 399 | 2 |
#include <stdio.h>
#define MAX 100000
int main() {
int n, i, a[MAX];
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
for (i = 0; i < n; i++) {
printf("node %d: key = %d, ", i + 1, a[i]);
if (i) {
printf("parent key = %d, ", a[(i + 1) / 2 - 1]);
}
if (2 * i + 1 <... | #include <stdio.h>
#define MAX 100000
int main() {
int n, i, a[MAX];
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
for (i = 0; i < n; i++) {
printf("node %d: key = %d, ", i + 1, a[i]);
if (i) {
printf("parent key = %d, ", a[(i + 1) / 2 - 1]);
}
if (2 * i + 1 <... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 0 | 182 | 2 |
#include <stdio.h>
int main() {
int i, n, k, A[251];
for (i = 0; i < 251; i++)
A[i] = 2000000001;
scanf("%d", &n);
for (i = 1; i < n + 1; i++)
scanf("%d", &A[i]);
for (i = 1; i < n + 1; i++) {
printf("node %d: key = %d, ", i, A[i]);
if (i != 1)
printf("parent key = %d, ", A[i / 2]);
... | #include <stdio.h>
int main() {
int i, n, k, A[251];
for (i = 0; i < 251; i++)
A[i] = 2000000001;
scanf("%d", &n);
for (i = 1; i < n + 1; i++)
scanf("%d", &A[i]);
for (i = 1; i < n + 1; i++) {
printf("node %d: key = %d, ", i, A[i]);
if (i != 1)
printf("parent key = %d, ", A[i / 2]);
... | [["+", 0, 57, 15, 23, 0, 16, 12, 16, 17, 72], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13]] | 0 | 203 | 2 |
#include <stdio.h>
#define NIL -1
int main() {
int i, n;
int A[502];
scanf("%d", &n);
for (i = 0; i < 502; i++) {
A[i] = NIL;
}
for (i = 1; i <= n; i++) {
scanf("%d", &A[i]);
}
for (i = 1; i <= n; i++) {
printf("node %d: key = %d, ", i, A[i]);
if (i != 1)
printf("parent key = %d, ... | #include <stdio.h>
#define NIL -2000000001
int main() {
int i, n;
int A[502];
scanf("%d", &n);
for (i = 0; i < 502; i++) {
A[i] = NIL;
}
for (i = 1; i <= n; i++) {
scanf("%d", &A[i]);
}
for (i = 1; i <= n; i++) {
printf("node %d: key = %d, ", i, A[i]);
if (i != 1)
printf("parent k... | [["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]] | 0 | 197 | 2 |
#include <stdio.h>
#define MAX 251
#define NIL -2000000001
struct node {
int key;
int parent_key;
int left_key;
int right_key;
};
typedef struct node Node;
int main() {
int n, i, size;
Node heap[MAX];
scanf("%d", &n);
for (i = 1; i <= n; i++) {
heap[i].key = NIL;
heap[i].parent_key = NIL;
... | #include <stdio.h>
#define MAX 251
#define NIL -2000000001
struct node {
int key;
int parent_key;
int left_key;
int right_key;
};
typedef struct node Node;
int main() {
int n, i, size;
Node heap[MAX];
scanf("%d", &n);
for (i = 1; i <= n; i++) {
heap[i].key = NIL;
heap[i].parent_key = NIL;
... | [["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 2, 3, 4, 0, 61, 0, 5, 0, 6], ["+", 0, 2, 3, 4, 0, 61, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 0 | 440 | 8 |
#include <stdio.h>
struct intree {
int parent;
int left;
int right;
int key;
};
int size;
struct intree list[100000];
int Parent(int i) { return list[i / 2].key; }
int Left(int i) { return list[2 * i].key; }
int Right(int i) { return list[2 * i + 1].key; }
int main(void) {
int i, j;
scanf("%d", &size)... | #include <stdio.h>
struct intree {
int parent;
int left;
int right;
int key;
};
int size;
struct intree list[100000];
int Parent(int i) { return list[i / 2].key; }
int Left(int i) { return list[2 * i].key; }
int Right(int i) { return list[2 * i + 1].key; }
int main(void) {
int i, j;
scanf("%d", &size)... | [["-", 15, 23, 0, 16, 31, 118, 28, 69, 28, 22], ["-", 15, 23, 0, 16, 31, 118, 28, 69, 0, 70], ["-", 15, 23, 0, 16, 31, 118, 28, 69, 0, 73], ["-", 0, 57, 15, 23, 0, 16, 31, 118, 17, 131], ["-", 0, 57, 15, 23, 0, 16, 31, 118, 119, 120], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13]] | 0 | 321 | 7 |
#include <math.h>
#include <stdio.h>
#define N 250
main() {
int n, i, *k[N], x;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", (k + i));
}
for (i = 1; i <= n; i++) {
printf("node %d:", i);
printf("key = %d, ", *(k + i));
if (i == 1) {
printf("left key = %d, ", *(k + 2 * i)... | #include <math.h>
#include <stdio.h>
#define N 250
main() {
int n, i, *k[N], x;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", (k + i));
}
for (i = 1; i <= n; i++) {
printf("node %d: ", i);
printf("key = %d, ", *(k + i));
if (i == 1) {
printf("left key = %d, ", *(k + 2 * i... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 0 | 309 | 10 |
#include <stdio.h>
#define N 250
int parent(int i) { return i / 2; }
int Left(int i) { return 2 * i; }
int Right(int i) { return 2 * i + 1; }
main() {
int i, n, h[N];
scanf("%d", &n);
for (i = 1; i < n + 1; i++) {
scanf("%d", &h[i]);
}
for (i = 1; i < n + 1; i++) {
if (i == 1) {
printf("node... | #include <stdio.h>
#define N 250
int parent(int i) { return i / 2; }
int Left(int i) { return 2 * i; }
int Right(int i) { return 2 * i + 1; }
main() {
int i, n, h[N];
scanf("%d", &n);
for (i = 1; i < n + 1; i++) {
scanf("%d", &h[i]);
}
for (i = 1; i < n + 1; i++) {
if (i == 1) {
printf("node... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 0 | 234 | 2 |
#include <stdio.h>
#define N 250
int parent(int);
int left(int);
int right(int);
main() {
int a, p, l, r, i, A[N];
scanf("%d", &a);
for (i = 1; i <= a; i++) {
scanf("%d", &A[i]);
}
for (i = 1; i <= a; i++) {
p = parent(i);
l = left(i);
r = right(i);
printf("node %d key = %d, :", i, A... | #include <stdio.h>
#define N 250
int parent(int);
int left(int);
int right(int);
main() {
int a, p, l, r, i, A[N];
scanf("%d", &a);
for (i = 1; i <= a; i++) {
scanf("%d", &A[i]);
}
for (i = 1; i <= a; i++) {
p = parent(i);
l = left(i);
r = right(i);
printf("node %d: key = %d, ", i, A... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 57, 15, 23, 0, 16, 31, 16, 17, 20], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 47], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 17, 20], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 17, 47], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0,... | 0 | 266 | 8 |
class BinaryTree():
def __init__(self):
self.root = None
def insert(self, insert_node):
p = None
r = self.root
while r:
p = r
if insert_node.value < r.value:
r = r.left
else:
r = r.right
if not p:
... | class BinaryTree():
def __init__(self):
self.root = None
def insert(self, insert_node):
p = None
r = self.root
while r:
p = r
if insert_node.value < r.value:
r = r.left
else:
r = r.right
if not p:
... | [["+", 64, 196, 0, 57, 15, 679, 31, 666, 0, 685], ["+", 0, 57, 64, 196, 0, 57, 15, 679, 17, 355], ["+", 0, 57, 75, 76, 8, 196, 0, 37, 0, 38]] | 5 | 582 | 3 |
import collections
sent = None
def insert(hoge, new_node, root):
parent_maybe = sent
now_looking = root
hoge[new_node]['node_id'] = new_node
while now_looking != sent:
parent_maybe = now_looking
if new_node < hoge[now_looking]['node_id']:
now_looking = hoge[now_looking]['lef... | import collections
sent = None
def insert(hoge, new_node, root):
parent_maybe = sent
now_looking = root
hoge[new_node]['node_id'] = new_node
while now_looking != sent:
parent_maybe = now_looking
if new_node < hoge[now_looking]['node_id']:
now_looking = hoge[now_looking]['lef... | [["-", 75, 76, 8, 196, 0, 1, 0, 666, 667, 60], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 0, 32]] | 5 | 993 | 2 |
class Tree():
def __init__(self):
self.root = None
def insert(self, key):
z = Node(key)
y = None
x = self.root
while x:
y = x
if z.key < x.key:
x = x.left
else:
x = x.right
z.parent = y
if... | class Tree():
def __init__(self):
self.root = None
def insert(self, key):
z = Node(key)
y = None
x = self.root
while x:
y = x
if z.key < x.key:
x = x.left
else:
x = x.right
z.parent = y
if... | [["+", 12, 41, 0, 652, 3, 4, 0, 319, 0, 131], ["+", 12, 41, 0, 652, 3, 4, 0, 319, 319, 22]] | 5 | 578 | 2 |
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int key;
int priority;
struct node *left;
struct node *right;
} Node;
Node *makeNode(int, int);
Node *rightRotate(Node *);
Node *leftRotate(Node *);
Node *insert(Node **, int, int);
Node *delete (Node **, int);
Node *KeyDelete(Node **, int);
int fin... | #include <stdio.h>
#include <stdlib.h>
typedef struct node {
int key;
int priority;
struct node *left;
struct node *right;
} Node;
Node *makeNode(int, int);
Node *rightRotate(Node *);
Node *leftRotate(Node *);
Node *insert(Node **, int, int);
Node *delete (Node **, int);
Node *KeyDelete(Node **, int);
int fin... | [["-", 8, 9, 0, 57, 64, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 57, 64, 1, 0, 2, 63, 22]] | 0 | 1,064 | 4 |
#include <bits/stdc++.h>
#define GET_MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define pr(...) \
cerr << GET_MACRO(__VA_ARGS__, pr6, pr5, pr4, pr3, pr2, pr1)(__VA_ARGS__) \
<< endl
#define pr1(a) (#a) << "=" << (a) << " "
#define pr2(a, b) p... | #include <bits/stdc++.h>
#define GET_MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define pr(...) \
cerr << GET_MACRO(__VA_ARGS__, pr6, pr5, pr4, pr3, pr2, pr1)(__VA_ARGS__) \
<< endl
#define pr1(a) (#a) << "=" << (a) << " "
#define pr2(a, b) p... | [["+", 0, 14, 8, 9, 0, 37, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 37, 0, 11, 17, 32]] | 1 | 1,580 | 2 |
(function main() {
const lines =
require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const n = Number(lines.shift());
lines.shift().split(' ').map(Number).forEach(function(key, i, a) {
console.log(`node ${i}: key = ${a[i]}, ` +
(i ? `parent key = ${a[Math.floor((i - 1) /... | (function main() {
const lines =
require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const n = Number(lines.shift());
lines.shift().split(' ').map(Number).forEach(function(key, i, a) {
console.log(`node ${i + 1}: key = ${a[i]}, ` +
(i ? `parent key = ${a[Math.floor((i - ... | [["+", 31, 16, 31, 561, 0, 562, 0, 16, 17, 72], ["+", 31, 16, 31, 561, 0, 562, 0, 16, 12, 555]] | 2 | 196 | 2 |
// (function main(){
// const lines = require('fs').readFileSync('/dev/stdin',
// 'utf8').trim().split('\n'); const n = Number(lines.shift());
// lines.shift().split(' ').map(Number).forEach(function(key, i, a) {
// console.log(`node ${i+1}: key = ${a[i++]}, `+((i-1)?`parent key =
// ${a[Math.floor(i/2)-1... | // (function main(){
// const lines = require('fs').readFileSync('/dev/stdin',
// 'utf8').trim().split('\n'); const n = Number(lines.shift());
// lines.shift().split(' ').map(Number).forEach(function(key, i, a) {
// console.log(`node ${i+1}: key = ${a[i++]}, `+((i-1)?`parent key =
// ${a[Math.floor(i/2)-1... | [["-", 63, 558, 500, 2, 3, 3, 0, 557, 0, 104], ["-", 63, 558, 500, 2, 3, 3, 0, 557, 0, 491], ["+", 63, 558, 500, 2, 3, 3, 0, 575, 0, 85], ["+", 63, 558, 500, 2, 3, 3, 0, 575, 374, 576]] | 2 | 163 | 27 |
import java.util.Scanner;
public class Main {
private static Scanner s = new Scanner(System.in);
public static void main(String[] args) {
int n = s.nextInt();
int[] a = new int[n + 1];
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= n; i++) {
a[i] = s.nextInt();
}
for (i... | import java.util.Scanner;
public class Main {
private static Scanner s = new Scanner(System.in);
public static void main(String[] args) {
int n = s.nextInt();
int[] a = new int[n + 1];
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= n; i++) {
a[i] = s.nextInt();
}
for (i... | [["+", 0, 1, 0, 492, 3, 4, 0, 16, 17, 72], ["+", 0, 492, 3, 4, 0, 16, 12, 5, 0, 62], ["+", 0, 492, 3, 4, 0, 16, 12, 5, 0, 491], ["-", 0, 492, 3, 4, 0, 16, 12, 5, 0, 491]] | 3 | 244 | 6 |
import java.util.*;
public class Main {
Scanner sc = new Scanner(System.in);
StringBuilder sb = new StringBuilder();
int H;
int[] A;
public static void main(String[] args) {
Main main = new Main();
main.in();
main.out();
}
public void in() {
H = sc.nextInt();
A = new int[H + 1];
... | import java.util.*;
public class Main {
Scanner sc = new Scanner(System.in);
StringBuilder sb = new StringBuilder();
int H;
int[] A;
public static void main(String[] args) {
Main main = new Main();
main.in();
main.out();
}
public void in() {
H = sc.nextInt();
A = new int[H + 1];
... | [["-", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491], ["+", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491]] | 3 | 363 | 2 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
static long changecount = 0;
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLin... |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
static long changecount = 0;
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLin... | [["-", 0, 492, 3, 4, 0, 16, 12, 5, 0, 491], ["+", 0, 492, 3, 4, 0, 16, 12, 5, 0, 491]] | 3 | 366 | 2 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
/**
* @param args
* @throws IOException
* @throws NumberFormatException
*/
public static void main(String[] args)
throws NumberFormatException, IOException {
// TODO Auto-generate... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
/**
* @param args
* @throws IOException
* @throws NumberFormatException
*/
public static void main(String[] args)
throws NumberFormatException, IOException {
// TODO Auto-generate... | [["-", 0, 11, 12, 504, 71, 16, 31, 16, 12, 499], ["+", 0, 11, 12, 504, 71, 16, 31, 16, 12, 22]] | 3 | 432 | 2 |
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = Integer.parseInt(in.next()), H[] = new int[n + 1];
for (int i = 1; i <= n; i++)
H[i] = Integer.parseInt(in.next());
PrintWriter out = new PrintWriter... |
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = Integer.parseInt(in.next()), H[] = new int[n + 1];
for (int i = 1; i <= n; i++)
H[i] = Integer.parseInt(in.next());
PrintWriter out = new PrintWrite... | [["-", 0, 492, 3, 4, 0, 504, 71, 16, 17, 85], ["+", 3, 4, 0, 504, 71, 16, 31, 16, 17, 48], ["+", 0, 492, 3, 4, 0, 504, 71, 16, 17, 72], ["+", 0, 492, 3, 4, 0, 504, 71, 16, 12, 499]] | 3 | 227 | 4 |
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define rep(i, begin, end) \
for ... | #include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define rep(i, begin, end) \
for ... | [["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 9, 0, 1, 0, 16, 17, 151]] | 1 | 268 | 4 |
#include <bits/stdc++.h>
using namespace std;
#define inf 1e9 + 7
typedef long long ll;
void solve(int n, const vector<ll> &a) {
for (int i = 0; i < n; i++) {
int sub = i + 1;
cout << "node " << sub;
cout << " key = " << a[i] << ",";
if (i)
cout << " parent key = " << a[sub / 2 - 1] << ",";
... | #include <bits/stdc++.h>
using namespace std;
#define inf 1e9 + 7
typedef long long ll;
void solve(int n, const vector<ll> &a) {
for (int i = 0; i < n; i++) {
int sub = i + 1;
cout << "node " << sub << ":";
cout << " key = " << a[i] << ",";
if (i)
cout << " parent key = " << a[sub / 2 - 1] << ... | [["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 228 | 5 |
#include <iostream>
using namespace std;
#define MAX 100000
int parent(int i) { return i / 2; }
int left(int i) { return i * 2; }
int right(int i) { return (i * 2 + 1); }
int main() {
int H, i, A[MAX + 1];
for (i = 1; i <= H; i++) {
cin >> A[i];
}
for (i = 1; i <= H; i++) {
cout << "node " << i << "... | #include <iostream>
using namespace std;
#define MAX 100000
int parent(int i) { return i / 2; }
int left(int i) { return i * 2; }
int right(int i) { return (i * 2 + 1); }
int main() {
int H, i, A[MAX + 1];
cin >> H;
for (i = 1; i <= H; i++) {
cin >> A[i];
}
for (i = 1; i <= H; i++) {
cout << "node... | [["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 216 | 4 |
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define SORT(c) sort((c).begin(), (c).end())
#define CLR(a) memset((&a), 0, sizeof(a)) // clear memory
#define dump(x) cerr << #x << " = " << (x) << endl; // debug... | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define SORT(c) sort((c).begin(), (c).end())
#define CLR(a) memset((&a), 0, sizeof(a)) // clear memory
#define dump(x) cerr << #x << " = " << (x) << endl; // debug... | [["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151]] | 1 | 211 | 4 |
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int *A = new int[n + 1];
for (int i = 1; i <= n; i++)
cin >> A[i];
for (int i = 1; i <= n; ++i) {
cout << "node " << i << ": key = " << A[i] << ", ";
if (i > 1)
cout << "parent key=" << A[i / 2] << ", ";
if (2 * i <... | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int *A = new int[n + 1];
for (int i = 1; i <= n; i++)
cin >> A[i];
for (int i = 1; i <= n; ++i) {
cout << "node " << i << ": key = " << A[i] << ", ";
if (i > 1)
cout << "parent key = " << A[i / 2] << ", ";
if (2 * i... | [["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 170 | 2 |
#include <bits/stdc++.h>
using namespace std;
int A[251];
int main() {
int H;
cin >> H;
for (int i = 1; i <= H; i++)
cin >> A[i];
cout << H;
for (int i = 1; i <= H; i++) {
cout << "node " << i << ": key = " << A[i] << ", ";
if (i != 1)
cout << "parent key = " << A[i / 2] << ", ";
if (i... | #include <bits/stdc++.h>
using namespace std;
int A[251];
int main() {
int H;
cin >> H;
for (int i = 1; i <= H; i++)
cin >> A[i];
for (int i = 1; i <= H; i++) {
cout << "node " << i << ": key = " << A[i] << ", ";
if (i != 1)
cout << "parent key = " << A[i / 2] << ", ";
if (i * 2 <= H)
... | [["-", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 171 | 4 |
#include <iostream>
#include <queue>
#include <sstream>
#include <string>
using namespace std;
struct dot {
int k, p, l, r;
};
int main(int argc, char **argv) {
int n;
while (cin >> n) {
dot p[n + 1];
for (int i = 1; i <= n; i++) {
cin >> p[i].k;
if (i / 2)
p[i].p = i / 2;
else
... | #include <iostream>
#include <queue>
#include <sstream>
#include <string>
using namespace std;
struct dot {
long long int k, p, l, r;
};
int main(int argc, char **argv) {
int n;
while (cin >> n) {
dot p[n + 100];
for (int i = 1; i <= n; i++) {
cin >> p[i].k;
if (i / 2)
p[i].p = i / 2;
... | [["+", 0, 122, 8, 123, 0, 124, 39, 86, 0, 96], ["-", 8, 9, 0, 43, 49, 80, 81, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 80, 81, 16, 12, 13], ["-", 0, 57, 64, 1, 0, 11, 31, 118, 119, 120], ["+", 0, 57, 64, 1, 0, 11, 31, 118, 119, 120], ["-", 75, 76, 0, 1, 0, 11, 31, 118, 119, 120], ["+", 75, 76, 0, 1, 0, 11, 31, 118, 119, 120... | 1 | 317 | 8 |
#include <iostream>
using namespace std;
#define MAX \
100000 // defineは文字列を指定した文字で置き換える。constは変数を格納している。
// 2分接点の各情報を出力する
int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }
int main() {
int... | #include <iostream>
using namespace std;
#define MAX \
100000 // defineは文字列を指定した文字で置き換える。constは変数を格納している。
// 2分接点の各情報を出力する
int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }
int main() {
int... | [["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 217 | 2 |
#include <iostream>
#include <vector>
using namespace std;
int parent(int i) { return i / 2; }
int left(int i) { return i * 2; }
int right(int i) { return i * 2 + 1; }
int main() {
int n;
cin >> n;
vector<int> a(n + 1);
for (int i = 1; i < n + 1; i++)
cin >> a[i];
for (int i = 1; i < n + 1; i++) {
c... | #include <iostream>
#include <vector>
using namespace std;
int parent(int i) { return i / 2; }
int left(int i) { return i * 2; }
int right(int i) { return i * 2 + 1; }
int main() {
int n;
cin >> n;
vector<int> a(n + 1);
for (int i = 1; i < n + 1; i++)
cin >> a[i];
for (int i = 1; i < n + 1; i++) {
c... | [["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 224 | 2 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 100000;
int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }
int main(void) {
int n;
cin >> n;
int A[n + 1];
for (int i = 1; i <= n; i++)
cin >> A[i];
for (int i ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 100000;
int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }
int main(void) {
int n;
cin >> n;
int A[n + 1];
for (int i = 1; i <= n; i++)
cin >> A[i];
for (int i ... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 210 | 8 |
#include <cmath>
#include <iostream>
using namespace std;
#define MAX 250
int parent(int i) { return (int)floor(i / 2); };
int left(int i) { return i * 2; }
int right(int i) { return i * 2 + 1; }
int main() {
int H;
int A[MAX + 1];
cin >> H;
for (int i = 1; i <= H; i++) {
cin >> A[i];
}
for (int... | #include <cmath>
#include <iostream>
using namespace std;
#define MAX 250
int parent(int i) { return (int)floor(i / 2); };
int left(int i) { return i * 2; }
int right(int i) { return i * 2 + 1; }
int main() {
int H;
int A[MAX + 1];
cin >> H;
for (int i = 1; i <= H; i++) {
cin >> A[i];
}
for (int... | [["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 234 | 10 |
#include <iostream>
using namespace std;
int H, N[800];
void print() {
for (int i = 1; i <= H; i++) {
cout << "node " << i << ": "
<< "key = " << N[i] << ", ";
if (N[i / 2] >= 1)
cout << "parent key = " << N[i / 2] << ", ";
if (i * 2 <= H)
cout << "left key = " << N[i * 2] << ", ";
... | #include <iostream>
using namespace std;
int H, N[3000];
void print() {
for (int i = 1; i <= H; i++) {
cout << "node " << i << ": "
<< "key = " << N[i] << ", ";
if (i / 2 >= 1)
cout << "parent key = " << N[i / 2] << ", ";
if (i * 2 <= H)
cout << "left key = " << N[i * 2] << ", ";
... | [["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 70], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 73]] | 1 | 199 | 5 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int h;
cin >> h;
int h_lst[h + 1];
for (int i = 1; i < h + 1; i++)
cin >> h_lst[i];
for (int i = 1; i < h + 1; i++) {
cout << "node " << i << ": key = " << h_lst[i] << ", ";
if (i > 1)
cout << "parent key = " << h_lst[i / 2] << ",... | #include <bits/stdc++.h>
using namespace std;
int main() {
int h;
cin >> h;
int h_lst[h + 1];
for (int i = 1; i < h + 1; i++)
cin >> h_lst[i];
for (int i = 1; i < h + 1; i++) {
cout << "node " << i << ": key = " << h_lst[i] << ", ";
if (i > 1)
cout << "parent key = " << h_lst[i / 2] << ",... | [["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 72], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 174 | 2 |
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
struct Node {
int key;
Node *p, *l, *r;
};
Node *NIL, *root;
void preorder(Node *u) {
if (u == NIL)
return;
cout << ' ' << u->key;
preorder(u->l);
preorder(u->r);
}
void inorder(Node *u) {
if (u == NIL)
return;
inor... | #include <cstdio>
#include <iostream>
#include <string>
using namespace std;
struct Node {
int key;
Node *p, *l, *r;
};
Node *NIL, *root;
void preorder(Node *u) {
if (u == NIL)
return;
cout << ' ' << u->key;
preorder(u->l);
preorder(u->r);
}
void inorder(Node *u) {
if (u == NIL)
return;
inor... | [["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 764 | 2 |
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int *Tree = new int[n + 1];
for (int i = 1; i <= n; i++) {
cin >> Tree[i];
}
for (int i = 1; i <= n; i++) {
cout << "node " << i + 1 << ": key = " << Tree[i];
if (i / 2 > 0) {
cout << ", parent key = " << Tree[i / 2]... | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int *Tree = new int[n + 1];
for (int i = 1; i <= n; i++) {
cin >> Tree[i];
}
for (int i = 1; i <= n; i++) {
cout << "node " << i << ": key = " << Tree[i];
if (i / 2 > 0) {
cout << ", parent key = " << Tree[i / 2];
... | [["-", 0, 16, 31, 16, 31, 16, 12, 16, 17, 72], ["-", 0, 16, 31, 16, 31, 16, 12, 16, 12, 13]] | 1 | 178 | 2 |
#include <stdio.h>
#define MAX 250
typedef struct Node {
int key;
Node *parent, *left, *right;
} Node;
Node *NIL, T[MAX];
void print(int n) {
int i;
Node *N;
for (i = 1; i <= n; i++) {
N = &T[i];
printf("node %d: key = %d, ", i + 1, N->key);
if (N->parent != NIL)
printf("parent key = %d, ... | #include <stdio.h>
#define MAX 250
typedef struct Node {
int key;
Node *parent, *left, *right;
} Node;
Node *NIL, T[MAX];
void print(int n) {
int i;
Node *N;
for (i = 1; i <= n; i++) {
N = &T[i];
printf("node %d: key = %d, ", i, N->key);
if (N->parent != NIL)
printf("parent key = %d, ", N... | [["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]] | 1 | 361 | 4 |
#include <array>
#include <iostream>
using namespace std;
int n;
int getP(int i) {
if (i / 2 < n)
return i / 2;
else
return 0;
}
int getL(int i) {
if (2 * i < n)
return 2 * i;
else
return 0;
}
int getR(int i) {
if (2 * i + 1 < n)
return 2 * i + 1;
else
return 0;
}
int main() {
a... | #include <array>
#include <iostream>
using namespace std;
int n;
int getP(int i) {
if (i / 2 <= n)
return i / 2;
else
return 0;
}
int getL(int i) {
if (2 * i <= n)
return 2 * i;
else
return 0;
}
int getR(int i) {
if (2 * i + 1 <= n)
return 2 * i + 1;
else
return 0;
}
int main() {
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]] | 1 | 259 | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.