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 |
|---|---|---|---|---|---|
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <v... | #include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <v... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 530 | 4 |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#includ... | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#includ... | [["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 631 | 2 |
#include <cstdio>
#include <iostream>
using namespace std;
const long N = 100001;
typedef struct {
long parent;
long left; // 1????????????
long
right_sib; //??????????????????(????????????????????¬?????????????????¨?????????)
} Node;
long n, d[N];
Node t[N];
void print(long a) {
printf("node %ld: par... | #include <cstdio>
#include <iostream>
using namespace std;
const long N = 100001;
typedef struct {
long parent;
long left; // 1????????????
long
right_sib; //??????????????????(????????????????????¬?????????????????¨?????????)
} Node;
long n, d[N];
Node t[N];
void print(long a) {
printf("node %ld: par... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 483 | 2 |
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct tree {
vector<int> children;
int depth;
int parent;
string type; // root, leef, internal node
};
tree trees[100000];
int calc_depth(int n) {
for (vector<int>::iterator i = trees[n].children.begin();
i < trees[n].chil... | #include <iostream>
#include <string>
#include <vector>
using namespace std;
struct tree {
vector<int> children;
int depth;
int parent;
string type; // root, leef, internal node
};
tree trees[100000];
int calc_depth(int n) {
for (vector<int>::iterator i = trees[n].children.begin();
i < trees[n].chil... | [["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]] | 1 | 446 | 2 |
#include <algorithm>
#include <cstdio>
#include <iostream>
#define N 100001
#define NIL -1
using namespace std;
struct Node {
int parent, left, right;
};
Node **T;
int *depth;
Node *newNode(int parent, int left, int right) {
Node *p = new Node;
p->parent = parent;
p->left = left;
p->right = right;
return... | #include <algorithm>
#include <cstdio>
#include <iostream>
#define N 100001
#define NIL -1
using namespace std;
struct Node {
int parent, left, right;
};
Node **T;
int *depth;
Node *newNode(int parent, int left, int right) {
Node *p = new Node;
p->parent = parent;
p->left = left;
p->right = right;
return... | [["+", 8, 9, 0, 7, 8, 9, 0, 43, 49, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 0, 21], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["-", 0, 11, 31, 118, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 31, 118, 28, 69, 341, 342, 0, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 7, 8, 9, 0,... | 1 | 580 | 8 |
#include <algorithm>
#include <iostream>
#include <iterator> //back_inserter
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string> //ノードのタイプ(root、internal node、leafのいずれか)を記録
#include <vector> //子のセットを記録
#define N_MAX 100000
#define MAX_DEPTH
#define NIL -1 //親や子などが存在しない場合に用いる
using namespace std;
//... | #include <algorithm>
#include <iostream>
#include <iterator> //back_inserter
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string> //ノードのタイプ(root、internal node、leafのいずれか)を記録
#include <vector> //子のセットを記録
#define N_MAX 100000
#define MAX_DEPTH
#define NIL -1 //親や子などが存在しない場合に用いる
using namespace std;
//... | [["-", 0, 52, 15, 339, 51, 16, 31, 118, 119, 120], ["+", 0, 52, 15, 339, 51, 16, 31, 118, 119, 120]] | 1 | 547 | 2 |
/*! if g++ -g alds_1_7_a.cpp -o alds_1_7_a.out; then ./alds_1_7_a.out <
* alds_1_7_a.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_a.cpp -o alds_1_7_a.out; then ./alds_1_7_a.out <
* alds_1_7_a.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... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]] | 1 | 556 | 2 |
#include <iostream>
using namespace std;
const int nil = -1;
struct Node {
int p, l, r;
};
Node T[100000];
int n, D[100000];
void print(int u) {
cout << "node" << u << ": ";
cout << "parent = " << T[u].p << ", ";
cout << "depth = " << D[u] << ", ";
if (T[u].p == nil)
cout << "root, ";
else if (T[u].... | #include <iostream>
using namespace std;
const int nil = -1;
struct Node {
int p, l, r;
};
Node T[100000];
int n, D[100000];
void print(int u) {
cout << "node " << u << ": ";
cout << "parent = " << T[u].p << ", ";
cout << "depth = " << D[u] << ", ";
if (T[u].p == nil)
cout << "root, ";
else if (T[u]... | [["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 459 | 2 |
// ALDS1_7_A
#include <iostream>
#include <vector>
using namespace std;
struct Node {
int parent;
int depth;
vector<int> children;
};
void cal_depth(vector<Node> &Tree, int p) {
if (Tree[p].parent != -1)
Tree[p].depth = Tree[Tree[p].parent].depth + 1;
for (int i = 0; i < Tree[p].children.size(); i++)
... | // ALDS1_7_A
#include <iostream>
#include <vector>
using namespace std;
struct Node {
int parent;
int depth;
vector<int> children;
};
void cal_depth(vector<Node> &Tree, int p) {
if (Tree[p].parent != -1)
Tree[p].depth = Tree[Tree[p].parent].depth + 1;
for (int i = 0; i < Tree[p].children.size(); i++)
... | [["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6]] | 1 | 470 | 2 |
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
int number; //
int parent_nu... | #define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
int number; //
int parent_nu... | [["-", 0, 11, 31, 118, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 31, 118, 28, 69, 341, 342, 0, 22], ["-", 31, 69, 28, 118, 28, 69, 341, 342, 0, 22], ["+", 31, 69, 28, 118, 28, 69, 341, 342, 0, 22]] | 1 | 668 | 12 |
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
struct Node {
struct Node *parent;
struct Node *left_child;
struct Node *right_sibling;
int key;
int depth;
Node(int key_ = -1)
: parent{nullptr}, left_child{nullptr},
right_sibling{nullptr}, key{key_}, depth{-1} {};
... | #include <iostream>
#include <stack>
#include <vector>
using namespace std;
struct Node {
struct Node *parent;
struct Node *left_child;
struct Node *right_sibling;
int key;
int depth;
Node(int key_ = -1)
: parent{nullptr}, left_child{nullptr},
right_sibling{nullptr}, key{key_}, depth{-1} {};
... | [["-", 0, 11, 31, 118, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 31, 118, 28, 69, 341, 342, 0, 22], ["-", 0, 11, 12, 66, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 12, 66, 28, 69, 341, 342, 0, 22]] | 1 | 578 | 4 |
#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 parent, left, right;
};
node t[100000];
int n, NI... | #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 parent, left, right;
};
node t[100000];
int n, NI... | [["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]] | 1 | 474 | 2 |
#include <iostream>
#include <vector>
using namespace std;
struct Tree {
int node;
int depth;
int parent;
vector<int> childs;
Tree(int id, int depth, int parent, vector<int> childs) {
this->node = id;
this->depth = depth;
this->parent = parent;
this->childs = childs;
}
void fix_tree(int d... | #include <iostream>
#include <vector>
using namespace std;
struct Tree {
int node;
int depth;
int parent;
vector<int> childs;
Tree(int id, int depth, int parent, vector<int> childs) {
this->node = id;
this->depth = depth;
this->parent = parent;
this->childs = childs;
}
void fix_tree(int d... | [["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 669 | 2 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a... | [["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]] | 1 | 453 | 2 |
#include <iostream>
using namespace std;
const long MAX = 100001;
const long NIL = -1;
struct Node {
long parent, leftChild, rightSibling;
};
struct Node T[MAX];
long n, Depth[MAX];
void print(long id) {
cout << "node " << id << ": ";
cout << "parent = " << T[id].parent << ", ";
cout << "depth = " << Depth[... | #include <iostream>
using namespace std;
const long MAX = 100001;
const long NIL = -1;
struct Node {
long parent, leftChild, rightSibling;
};
struct Node T[MAX];
long n, Depth[MAX];
void print(long id) {
cout << "node " << id << ": ";
cout << "parent = " << T[id].parent << ", ";
cout << "depth = " << Depth[... | [["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6]] | 1 | 467 | 2 |
//
// Created by ?????°?????? on 2016/04/05.
//
#include <iostream>
using namespace std;
const int MAX = 100000;
const int NIL = -1;
struct Node {
// ????????????????§????
int parent;
int left_child;
int right_sibling;
};
Node T[MAX];
int n, D[MAX];
void print(int u) {
int i, c;
cout << "Node " << u << ... | //
// Created by ?????°?????? on 2016/04/05.
//
#include <iostream>
using namespace std;
const int MAX = 100000;
const int NIL = -1;
struct Node {
// ????????????????§????
int parent;
int left_child;
int right_sibling;
};
Node T[MAX];
int n, D[MAX];
void print(int u) {
int i, c;
cout << "node " << u << ... | [["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 475 | 4 |
#include <iostream>
#include <string>
#define MAX 100005
#define NIL -1
using namespace std;
struct Node {
int parent, left, right;
};
Node Nodes[MAX];
int node_num;
int Depth[MAX];
void set_depth(int num, int depth) {
Depth[num] = depth;
if (Nodes[num].right != NIL) {
set_depth(Nodes[num].right, depth);... | #include <iostream>
#include <string>
#define MAX 100005
#define NIL -1
using namespace std;
struct Node {
int parent, left, right;
};
Node Nodes[MAX];
int node_num;
int Depth[MAX];
void set_depth(int num, int depth) {
Depth[num] = depth;
if (Nodes[num].right != NIL) {
set_depth(Nodes[num].right, depth);... | [["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]] | 1 | 507 | 2 |
#include <iostream>
#include <list>
#include <stdlib.h>
using namespace std;
bool linear_search(int *array, int size, int num);
void print_children(int *children, int size);
struct graph {
int parent_id;
int child_num;
int depth;
int *children;
};
int main() {
int n;
cin >> n;
graph *g = (graph *)calloc(... | #include <iostream>
#include <list>
#include <stdlib.h>
using namespace std;
bool linear_search(int *array, int size, int num);
void print_children(int *children, int size);
struct graph {
int parent_id;
int child_num;
int depth;
int *children;
};
int main() {
int n;
cin >> n;
graph *g = (graph *)calloc(... | [["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]] | 1 | 507 | 2 |
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>... | #include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>... | [["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 526 | 4 |
#include <iostream>
#include <memory>
#include <vector>
using namespace std;
struct Node {
int id;
int depth;
string state;
shared_ptr<Node> parent;
vector<shared_ptr<Node>> children;
Node() : id(-1), state("root") {}
Node(int id) : id(id), state("root"), depth(0) {
parent = shared_ptr<Node>(new... | #include <iostream>
#include <memory>
#include <vector>
using namespace std;
struct Node {
int id;
int depth;
string state;
shared_ptr<Node> parent;
vector<shared_ptr<Node>> children;
Node() : id(-1), state("root") {}
Node(int id) : id(id), state("root"), depth(0) {
parent = shared_ptr<Node>(new... | [["-", 0, 1, 0, 16, 12, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 12, 16, 12, 5, 0, 6]] | 1 | 566 | 31 |
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Node {
public:
int id;
int parent;
int depth;
string type;
vector<int> child;
Node() : id(-1), parent(-1), depth(-1), type(""){};
};
vector<Node> root;
void dfs(int id, int d) {
if (root[id].depth < ... | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Node {
public:
int id;
int parent;
int depth;
string type;
vector<int> child;
Node() : id(-1), parent(-1), depth(-1), type(""){};
};
vector<Node> root;
void dfs(int id, int d) {
if (root[id].depth < ... | [["-", 64, 9, 0, 1, 0, 11, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 11, 12, 5, 0, 6], ["-", 0, 9, 0, 1, 0, 11, 12, 5, 0, 6], ["+", 0, 9, 0, 1, 0, 11, 12, 5, 0, 6]] | 1 | 587 | 4 |
#include <bits/stdc++.h>
using namespace std;
int par[100000];
struct node {
node *next;
int key;
};
node *head[100000];
void mk_node(int key, node *next, node *prev) {
node *n = (node *)malloc(sizeof(node));
n->key = key;
n->next = next;
prev->next = n;
}
void insert(int x, int i) { mk_node(x, head[i]->... | #include <bits/stdc++.h>
using namespace std;
int par[100000];
struct node {
node *next;
int key;
};
node *head[100000];
void mk_node(int key, node *next, node *prev) {
node *n = (node *)malloc(sizeof(node));
n->key = key;
n->next = next;
prev->next = n;
}
void insert(int x, int i) { mk_node(x, head[i]->... | [["-", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 486 | 2 |
#include <bits/stdc++.h>
using namespace std;
struct node {
int key;
node *next;
};
node L;
node *nil = &L;
int root;
node t[100000];
int main() {
int n, par[100000];
cin >> n;
for (int i = 0; i < n; i++)
par[i] = -1;
for (int i = 0; i < n; i++) {
int a, b, c;
cin >> a >> b;
node *pre = &t[... | #include <bits/stdc++.h>
using namespace std;
struct node {
int key;
node *next;
};
node L;
node *nil = &L;
int root;
node t[100000];
int main() {
int n, par[100000];
cin >> n;
for (int i = 0; i < n; i++)
par[i] = -1;
for (int i = 0; i < n; i++) {
int a, b, c;
cin >> a >> b;
node *pre = &t[... | [["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6]] | 1 | 382 | 2 |
#include <iostream>
#define N 100000
using namespace std;
struct Node {
int p, l, r;
};
Node t[N];
void print_node(int x) {
int s = t[x].l;
if (s > 0)
cout << "[" << s;
else if (s == -1) {
cout << "[]";
return;
}
while (1) {
if (t[s].r == -1)
break;
else
cout << " ,";
c... | #include <iostream>
#define N 100000
using namespace std;
struct Node {
int p, l, r;
};
Node t[N];
void print_node(int x) {
int s = t[x].l;
if (s >= 0)
cout << "[" << s;
else if (s == -1) {
cout << "[]";
return;
}
while (1) {
if (t[s].r == -1)
break;
else
cout << ", ";
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 421 | 4 |
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1
struct Node {
int parent, left, right;
};
Node node[MAX];
int n, depth[MAX];
void print(int u) {
int i, c;
cout << "node " << u << ": ";
cout << "parent = " << node[u].parent << ", ";
cout << "depth = " << depth[u] << ", ";
if (no... | #include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1
struct Node {
int parent, left, right;
};
Node node[MAX];
int n, depth[MAX];
void print(int u) {
int i, c;
cout << "node " << u << ": ";
cout << "parent = " << node[u].parent << ", ";
cout << "depth = " << depth[u] << ", ";
if (no... | [["-", 0, 11, 31, 118, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 31, 118, 28, 69, 341, 342, 0, 22]] | 1 | 482 | 2 |
#include <cstdio>
#include <iostream>
using namespace std;
static const int MAX_NUM = 100000;
static const int NOELEM = -1;
struct stNode {
int parent;
int left;
int right;
};
int main(void) {
int i, j;
int key;
int nums;
int num;
int sun;
stNode elem[MAX_NUM];
stNode *pNode;
scanf("%d", &num)... | #include <cstdio>
#include <iostream>
using namespace std;
static const int MAX_NUM = 100000;
static const int NOELEM = -1;
struct stNode {
int parent;
int left;
int right;
};
int main(void) {
int i, j;
int key;
int nums;
int num;
int sun;
stNode elem[MAX_NUM];
stNode *pNode;
scanf("%d", &num)... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 418 | 2 |
#include <iostream>
using namespace std;
static const int MAX = 100006;
static const int NO = -1;
struct node {
int p, l, r;
};
node tree[MAX];
int d[MAX] = {};
void printchild(int u) {
int c;
if (tree[u].l == NO) {
cout << ']';
}
c = tree[u].l;
while (c != NO) {
cout << c;
c = tree[c].r;
... | #include <iostream>
using namespace std;
static const int MAX = 100006;
static const int NO = -1;
struct node {
int p, l, r;
};
node tree[MAX];
int d[MAX] = {};
void printchild(int u) {
int c;
if (tree[u].l == NO) {
cout << ']';
}
c = tree[u].l;
while (c != NO) {
cout << c;
c = tree[c].r;
... | [["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 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 | 505 | 4 |
#include <iostream>
#include <string>
#include <vector>
struct TNode {
int Index;
TNode *Parent;
std::vector<TNode *> Children;
TNode();
};
TNode::TNode() {
Index = -1;
Parent = NULL;
Children.clear();
}
typedef std::vector<TNode> TRootedTree;
void AddNode(TRootedTree &Tree) {
int Index;
std::cin... | #include <iostream>
#include <string>
#include <vector>
struct TNode {
int Index;
TNode *Parent;
std::vector<TNode *> Children;
TNode();
};
TNode::TNode() {
Index = -1;
Parent = NULL;
Children.clear();
}
typedef std::vector<TNode> TRootedTree;
void AddNode(TRootedTree &Tree) {
int Index;
std::cin... | [["+", 8, 9, 0, 37, 0, 2, 3, 4, 0, 21], ["+", 0, 37, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 37, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 37, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 481 | 4 |
#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 id;
node *parent;
vector<node *> child;
int depth;
... | #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 id;
node *parent;
vector<node *> child;
int depth;
... | [["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 491 | 2 |
#include <stdio.h>
#include <string>
#define MAX 100000
struct Node {
int parent;
int left;
int right;
int depth;
};
Node N[MAX];
void setDepth(Node &n, int depth) {
Node *cur = &n;
while (true) {
cur->depth = depth;
if (cur->left >= 0) {
setDepth(N[cur->left], depth + 1);
}
if (cu... | #include <stdio.h>
#include <string>
#define MAX 100000
struct Node {
int parent;
int left;
int right;
int depth;
};
Node N[MAX];
void setDepth(Node &n, int depth) {
Node *cur = &n;
while (true) {
cur->depth = depth;
if (cur->left >= 0) {
setDepth(N[cur->left], depth + 1);
}
if (cu... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 545 | 2 |
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1
struct Node {
int parent, left, right;
};
Node T[MAX];
int n, D[MAX];
// D[u]: the depth of u
void setDepth(int u, int p) {
// u is a node
// p is a depth
D[u] = p;
if (T[u].left != NIL) {
setDepth(T[u].left, p + 1);
}
if (T... | #include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1
struct Node {
int parent, left, right;
};
Node T[MAX];
int n, D[MAX];
// D[u]: the depth of u
void setDepth(int u, int p) {
// u is a node
// p is a depth
D[u] = p;
if (T[u].left != NIL) {
setDepth(T[u].left, p + 1);
}
if (T... | [["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]] | 1 | 494 | 2 |
#include <bits/stdc++.h>
#define Z -1
using namespace std;
struct NO {
int p, l, r;
};
struct NO T[100000];
int D[100000] = {Z};
int rec(int u, int p) {
D[u] = p;
if (T[u].r != Z)
rec(T[u].r, p);
if (T[u].l != Z)
rec(T[u].l, p + 1);
}
int main() {
int a, b, c, n, l, r, j, k, i;
for (cin >> n, i = 0;... | #include <bits/stdc++.h>
#define Z -1
using namespace std;
struct NO {
int p, l, r;
};
struct NO T[100000];
int D[100000] = {Z};
int rec(int u, int p) {
D[u] = p;
if (T[u].r != Z)
rec(T[u].r, p);
if (T[u].l != Z)
rec(T[u].l, p + 1);
}
int main() {
int a, b, c, n, l, r, j, k, i;
for (cin >> n, i = 0;... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 410 | 2 |
#include <algorithm>
#include <iostream>
#include <limits>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define INT_MAX 2147483647
#define INT_MIN -2147483647
#define NUM 10000
#define INVALID_IDX -1
using namespace std;
struct TreeNode {
int p, l, r;
};
TreeNode t[NUM];
int D[NUM];
void... | #include <algorithm>
#include <iostream>
#include <limits>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define INT_MAX 2147483647
#define INT_MIN -2147483647
#define NUM 100005
#define INVALID_IDX -1
using namespace std;
struct TreeNode {
int p, l, r;
};
TreeNode t[NUM];
int D[NUM];
voi... | [["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 486 | 4 |
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define NIL -1
#define N 10005
struct Node {
int p, l, r;
};
Node T[N];
int n, r, D[N];
void print(int u) {
int i, c;
cout << "node " << u << " ";
cou... | #include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define NIL -1
#define N 100005
struct Node {
int p, l, r;
};
Node T[N];
int n, r, D[N];
void print(int u) {
int i, c;
cout << "node " << u << ": ";
c... | [["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 477 | 4 |
#include <cstdio>
#include <iostream>
using namespace std;
#define maxn 100005
#define NTL -1
struct node {
int p, l, r;
} t[maxn];
int n, d[maxn];
void print(int u) {
int i, c;
cout << "node " << u << ": ";
cout << "parent = " << t[u].p << ", ";
cout << "depth = " << d[u] << ", ";
if (t[u].p == NTL)
... | #include <cstdio>
#include <iostream>
using namespace std;
#define maxn 100005
#define NTL -1
struct node {
int p, l, r;
} t[maxn];
int n, d[maxn];
void print(int u) {
int i, c;
cout << "node " << u << ": ";
cout << "parent = " << t[u].p << ", ";
cout << "depth = " << d[u] << ", ";
if (t[u].p == NTL)
... | [["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6]] | 1 | 461 | 2 |
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1
//?????????????????¨??????
// left-child right-sibling representation
struct node {
int parent;
int left;
int right;
};
node T[MAX];
int depth[MAX];
int n;
void print(int u) {
cout << "node " << u << ": ";
cout << "parent = " << T[u... | #include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1
//?????????????????¨??????
// left-child right-sibling representation
struct node {
int parent;
int left;
int right;
};
node T[MAX];
int depth[MAX];
int n;
void print(int u) {
cout << "node " << u << ": ";
cout << "parent = " << T[u... | [["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6]] | 1 | 465 | 2 |
#include <iostream>
#include <stdio.h>
using namespace std;
#define N_MAX 100000
#define NIL -1
struct Node {
int p, l, r;
};
Node T[N_MAX];
int main() {
int n, i, j, v, d, x, y;
cin >> n;
//??¨????????????
for (i = 0; i < N_MAX; i++) {
T[i].p = -1;
T[i].r = T[i].l = NIL;
}
//??¨?????\???
... | #include <iostream>
#include <stdio.h> //printf
using namespace std;
#define N_MAX 100000
#define NIL -1
struct Node {
int p, l, r;
};
Node T[N_MAX];
int main() {
int n, i, j, v, d, x, y;
cin >> n;
//??¨????????????
for (i = 0; i < N_MAX; i++) {
T[i].p = -1;
T[i].r = T[i].l = NIL;
}
//??¨??... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 412 | 2 |
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i =... | #include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) 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 | 566 | 4 |
#include <iostream>
#include <string>
using namespace std;
class Tree;
class Node {
public:
enum TYPE { NONE, ROOT, INTERNAL_NODE, LEAF };
TYPE type;
Node(Tree *T, int ID, Node *PARENT, int LEFT, int RIGHT, int C,
int CHILD_LEFT = -1) {
t = T;
id = ID;
parent = PARENT;
left = LEFT;
ri... | #include <iostream>
#include <string>
using namespace std;
class Tree;
class Node {
public:
enum TYPE { NONE, ROOT, INTERNAL_NODE, LEAF };
TYPE type;
Node(Tree *T, int ID, Node *PARENT, int LEFT, int RIGHT, int C,
int CHILD_LEFT = -1) {
t = T;
id = ID;
parent = PARENT;
left = LEFT;
ri... | [["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 0, 9, 0, 57, 64, 37, 0, 16, 17, 72], ["+", 0, 9, 0, 57, 64, 37, 0, 16, 12, 13]] | 1 | 1,315 | 3 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
const int INF = 0x3f3f3f3f;
const int NIL = -1;
const int MAXN = 100005;
struct Node {
int p, l, r;
} T[MAXN];
int n, D[MAXN];
void print(int u) {
cout << "Node" << u << ": paren... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
const int INF = 0x3f3f3f3f;
const int NIL = -1;
const int MAXN = 100005;
struct Node {
int p, l, r;
} T[MAXN];
int n, D[MAXN];
void print(int u) {
cout << "node " << u << ": pare... | [["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 459 | 2 |
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
struct Node {
string type;
int depth;
int parent = -1;
vector<int> child;
};
int main() {
int n;
Node node[1000];
queue<Node *> q;
int depth = 0;
cin >> n;
for (int i = 0; i < n; i++... | #include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
struct Node {
string type;
int depth;
int parent = -1;
vector<int> child;
};
int main() {
int n;
Node node[100000];
queue<Node *> q;
int depth = 0;
cin >> n;
for (int i = 0; i < n; i... | [["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 499 | 4 |
/**
*
*/
// #include {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <forward_list>
#include <fstream>
#include <functional>
#include... | /**
*
*/
// #include {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <forward_list>
#include <fstream>
#include <functional>
#include... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 3,701 | 2 |
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1
struct node {
int parent;
int left;
int right;
};
node tree[MAX];
int d[MAX] = {};
void depth(int u, int s) {
d[u] = s;
if (tree[u].right != NIL)
depth(tree[u].right, s);
if (tree[u].left != NIL)
depth(tree[u].left, s + 1... | #include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1
struct node {
int parent;
int left;
int right;
};
node tree[MAX];
int d[MAX] = {};
void depth(int u, int s) {
d[u] = s;
if (tree[u].right != NIL)
depth(tree[u].right, s);
if (tree[u].left != NIL)
depth(tree[u].left, s + 1... | [["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 480 | 2 |
#include <iostream>
using namespace std;
#define MAX 100000 + 5
#define NIL -1
struct Node {
int parent;
int left;
int right;
};
Node T[MAX];
int n, D[MAX];
void Print(int u);
int Rec(int u, int p);
int main() {
cin >> n;
for (int i = 0; i < n; ++i)
T[i].parent = T[i].left = T[i].right = NIL;
int ... | #include <iostream>
using namespace std;
#define MAX 100000 + 5
#define NIL -1
struct Node {
int parent;
int left;
int right;
};
Node T[MAX];
int n, D[MAX];
void Print(int u);
int Rec(int u, int p);
int main() {
cin >> n;
for (int i = 0; i < n; ++i)
T[i].parent = T[i].left = T[i].right = NIL;
int ... | [["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 479 | 4 |
#include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
#define FOR(k, m, n) for (int(k) = (m); (k) < (n); (k)++)
#define REP(i, n) FOR((i), 0, (n))
#define LL long long
#define MAX 100005
#define NIL -1
struct Node {
int parent, left, right;
};
Node tree[MAX];
int n, dep... | #include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
#define FOR(k, m, n) for (int(k) = (m); (k) < (n); (k)++)
#define REP(i, n) FOR((i), 0, (n))
#define LL long long
#define MAX 100005
#define NIL -1
struct Node {
int parent, left, right;
};
Node tree[MAX];
int n, dep... | [["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 461 | 4 |
#include <cstdint>
#include <vector>
using namespace std;
#define TREE_SIZE 100000
struct node_t {
int32_t parent;
int32_t left_child;
int32_t right_sibling;
};
static node_t trees[TREE_SIZE];
void rooted_tree_init() {
for (uint32_t i = 0; i < TREE_SIZE; i++) {
trees[i].parent = -1;
trees[i].left_c... | #include <cstdint>
#include <vector>
using namespace std;
#define TREE_SIZE 100000
struct node_t {
int32_t parent;
int32_t left_child;
int32_t right_sibling;
};
static node_t trees[TREE_SIZE];
void rooted_tree_init() {
for (uint32_t i = 0; i < TREE_SIZE; i++) {
trees[i].parent = -1;
trees[i].left_c... | [["-", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22]] | 1 | 554 | 2 |
#include <stdio.h>
#define N 100000
#define Nill -1
struct Tree {
int p, l, r;
};
int n;
struct Tree T[N];
int D[N];
void getDepth(int u, int p) {
D[u] = p;
if (T[u].r != Nill)
getDepth(T[u].r, p);
if (T[u].l != Nill)
getDepth(T[u].l, p + 1);
}
void Print(int r) {
getDepth(r, 0);
int i;
int g;
... | #include <stdio.h>
#define N 100000
#define Nill -1
struct Tree {
int p, l, r;
};
int n;
struct Tree T[N];
int D[N];
void getDepth(int u, int p) {
D[u] = p;
if (T[u].r != Nill)
getDepth(T[u].r, p);
if (T[u].l != Nill)
getDepth(T[u].l, p + 1);
}
void Print(int r) {
getDepth(r, 0);
int i;
int g;
... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 495 | 2 |
// tree structure
// input id, number of sibling and each of sibling number, output id, parent,
// depth and type(root, internal and external)
#include <iostream>
typedef struct {
int parent;
int left_child;
int next_sibling;
int child;
} node;
int depth(int);
node *T;
int count;
int main() {
int n, x, y, z, ... | // tree structure
// input id, number of sibling and each of sibling number, output id, parent,
// depth and type(root, internal and external)
#include <iostream>
typedef struct {
int parent;
int left_child;
int next_sibling;
int child;
} node;
int depth(int);
node *T;
int count;
int main() {
int n, x, y, z, ... | [["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["-", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 461 | 6 |
//#define FILE_INPUT_DEFINE
#ifdef FILE_INPUT_DEFINE
#include <fstream>
#endif // FILE_INPUT_DEFINE
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
struct Tree {
int parent;
int right;
int left;
Tree() { parent = right = left = -1; }
};
#define MAX 100000
Tree tree[MAX];
int m... | //#define FILE_INPUT_DEFINE
#ifdef FILE_INPUT_DEFINE
#include <fstream>
#endif // FILE_INPUT_DEFINE
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
struct Tree {
int parent;
int right;
int left;
Tree() { parent = right = left = -1; }
};
#define MAX 100000
Tree tree[MAX];
int m... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 409 | 2 |
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
typedef struct {
int parent = -1;
int depth = 0;
std::string type;
std::vector<int> children;
} Node;
int main() {
int n;
std::cin >> n;
std::vector<Node> tree(n);
for (int i = 0; i < n; ++i) {
int id, ch... | #include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
typedef struct {
int parent = -1;
int depth = 0;
std::string type;
std::vector<int> children;
} Node;
int main() {
int n;
std::cin >> n;
std::vector<Node> tree(n);
for (int i = 0; i < n; ++i) {
int id, ch... | [["-", 0, 57, 64, 1, 0, 11, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 11, 12, 5, 0, 6]] | 1 | 460 | 2 |
#include <iostream>
#include <set>
#include <vector>
using namespace std;
struct node {
int id;
int k;
int depth;
int parent;
vector<int> child;
};
int main() {
int n, id, k;
cin >> n;
vector<node> tree;
tree.resize(n);
for (int i = 0; i < n; i++) {
tree[i].parent = -1;
tree[i].depth = 0;
... | #include <iostream>
#include <set>
#include <vector>
using namespace std;
struct node {
int id;
int k;
int depth;
int parent;
vector<int> child;
};
int main() {
int n, id, k;
cin >> n;
vector<node> tree;
tree.resize(n);
for (int i = 0; i < n; i++) {
tree[i].parent = -1;
tree[i].depth = 0;
... | [["+", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]] | 1 | 488 | 3 |
#include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, x, n) for (int i = x; i < n; i++)
#define ... | #include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, x, n) for (int i = x; i < n; i++)
#define ... | [["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 545 | 4 |
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define llong long long
#define IFY 2000000000
#define MAX 100005
#define NIL -1
using namespace std;
struct Node {
int p, l, r;
};
Node T[MAX];
int D[MAX];
void print(int u) {
int j, c;
prin... | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define llong long long
#define IFY 2000000000
#define MAX 100005
#define NIL -1
using namespace std;
struct Node {
int p, l, r;
};
Node T[MAX];
int D[MAX];
void print(int u) {
int j, c;
prin... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67], ["-", 0, 14, 8, 9, 0, 14, 8, 9, 0, 45], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["-", 0, 14, 8, 9, 0, 14, 8, 9, 0, 46]] | 1 | 466 | 10 |
#include <iostream>
using namespace std;
#define MAX 100001
#define NIL -1
struct Node {
int parent, right, left;
};
struct Node D[MAX];
int T[MAX];
void rec(int u, int p) {
T[u] = p;
if (D[u].right != NIL)
rec(D[u].right, p);
if (D[u].left != NIL)
rec(D[u].left, p + 1);
}
void print(int u) {
int p;
... | #include <iostream>
using namespace std;
#define MAX 100001
#define NIL -1
struct Node {
int parent, right, left;
};
struct Node D[MAX];
int T[MAX];
void rec(int u, int p) {
T[u] = p;
if (D[u].right != NIL)
rec(D[u].right, p);
if (D[u].left != NIL)
rec(D[u].left, p + 1);
}
void print(int u) {
int p;
... | [["-", 75, 76, 0, 57, 64, 1, 0, 16, 17, 151], ["-", 75, 76, 0, 57, 64, 1, 0, 16, 12, 22]] | 1 | 505 | 2 |
#include <bits/stdc++.h>
using namespace std;
#define NIL -1
int n, D[1000001];
struct node {
int p, l, r;
};
node tree[1000001];
void print(int u) {
int i, c;
cout << "node " << u << ": ";
cout << "parent = " << tree[u].p << ", ";
cout << "depth = " << D[u] << ", ";
if (tree[u].p == NIL)
cout << "root... | #include <bits/stdc++.h>
using namespace std;
#define NIL -1
int n, D[1000001];
struct node {
int p, l, r;
};
node tree[1000001];
void print(int u) {
int i, c;
cout << "node " << u << ": ";
cout << "parent = " << tree[u].p << ", ";
cout << "depth = " << D[u] << ", ";
if (tree[u].p == NIL)
cout << "root... | [["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6]] | 1 | 462 | 2 |
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_A&lang=jp
*/
//根付き木
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef struct Node {
// int num; //ノード番号
int parent; //親
vector<int> children;
string type;
} Node;
Node tree[100000];
int dep(int k) {
int d... | /*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_A&lang=jp
*/
//根付き木
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef struct Node {
// int num; //ノード番号
int parent; //親
vector<int> children;
string type;
} Node;
Node tree[100000];
int dep(int k) {
int d... | [["-", 8, 9, 0, 1, 0, 11, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 11, 12, 5, 0, 6]] | 1 | 458 | 2 |
#include <iostream>
using namespace std;
#define MAXN 100005
#define NIL -1
struct Node {
int p, l, r;
};
Node T[MAXN];
int n, D[MAXN];
void print(int u) {
int i, c;
cout << "node" << u << ": ";
cout << "parent = " << T[u].p << ", ";
cout << "depth = " << D[u] << ", ";
if (T[u].p == NIL) {
cout << ... | #include <iostream>
using namespace std;
#define MAXN 100005
#define NIL -1
struct Node {
int p, l, r;
};
Node T[MAXN];
int n, D[MAXN];
void print(int u) {
int i, c;
cout << "node " << u << ": ";
cout << "parent = " << T[u].p << ", ";
cout << "depth = " << D[u] << ", ";
if (T[u].p == NIL) {
cout <<... | [["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 494 | 2 |
#include <iostream>
#define MAX 100005
#define NIL (-1)
using namespace std;
int D[MAX], n;
struct Node {
int parent;
int left;
int right;
} T[MAX];
void print(int u) {
int i, c;
cout << "node " << u << ": ";
cout << "parent = " << T[u].parent << ", ";
cout << "depth = " << D[u] << ", ";
if (T[u].p... | #include <iostream>
#define MAX 100005
#define NIL (-1)
using namespace std;
int D[MAX], n;
struct Node {
int parent;
int left;
int right;
} T[MAX];
void print(int u) {
int i, c;
cout << "node " << u << ": ";
cout << "parent = " << T[u].parent << ", ";
cout << "depth = " << D[u] << ", ";
if (T[u].p... | [["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 483 | 2 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) f... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) f... | [["-", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 539 | 2 |
#include <iostream>
#include <vector>
using namespace std;
struct NODE {
int id = -100;
int parent = -1;
int num_children = -100;
int depth = -100;
vector<int> children;
};
void check_depth(NODE *nodes, int id, int d) {
nodes[id].depth = d;
for (int i = 0; i < nodes[id].num_children; ++i) {
check_d... | #include <iostream>
#include <vector>
using namespace std;
struct NODE {
int id = -100;
int parent = -1;
int num_children = -100;
int depth = -100;
vector<int> children;
};
void check_depth(NODE *nodes, int id, int d) {
nodes[id].depth = d;
for (int i = 0; i < nodes[id].num_children; ++i) {
check_d... | [["-", 0, 11, 31, 118, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 31, 118, 28, 69, 341, 342, 0, 22]] | 1 | 471 | 2 |
#include <bits/stdc++.h>
/*#include<iostream>
#include<algorithm>
#include<climits>*/
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define rep1(i, a, b) for (int i = a; i <= (b); ++i)
#define per(i, a, ... | #include <bits/stdc++.h>
/*#include<iostream>
#include<algorithm>
#include<climits>*/
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define rep1(i, a, b) for (int i = a; i <= (b); ++i)
#define per(i, a, ... | [["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]] | 1 | 539 | 6 |
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1
struct Node {
int p, l, r;
};
Node T[MAX];
int n, D[MAX];
void print(int u) {
cout << "node " << u << ": " << flush;
cout << "parent = " << T[u].p << ", " << flush;
cout << "depth = " << D[u] << ", " << flush;
if (T[u].p == NIL) {
... | #include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1
struct Node {
int p, l, r;
};
Node T[MAX];
int n, D[MAX];
void print(int u) {
cout << "node " << u << ": " << flush;
cout << "parent = " << T[u].p << ", " << flush;
cout << "depth = " << D[u] << ", " << flush;
if (T[u].p == NIL) {
... | [["-", 0, 11, 31, 118, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 31, 118, 28, 69, 341, 342, 0, 22]] | 1 | 503 | 2 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i, n) for (int i = 0;... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i, n) for (int i = 0;... | [["-", 0, 57, 15, 339, 51, 16, 31, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 16, 31, 118, 119, 120]] | 1 | 492 | 2 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const double... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const double... | [["-", 0, 11, 31, 118, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 31, 118, 28, 69, 341, 342, 0, 22]] | 1 | 527 | 2 |
#include <algorithm>
#include <iostream>
#include <list>
#include <math.h>
#include <stdio.h>
#include <utility>
#include <vector>
using namespace std;
int n;
struct node {
int parent, depth;
vector<int> child;
};
node nd[100000];
void CalcDepth(int r) {
if (nd[r].child.size() != 0) {
for (int i = 0; i < nd... | #include <algorithm>
#include <iostream>
#include <list>
#include <math.h>
#include <stdio.h>
#include <utility>
#include <vector>
using namespace std;
int n;
struct node {
int parent, depth;
vector<int> child;
};
node nd[100000];
void CalcDepth(int r) {
if (nd[r].child.size() != 0) {
for (int i = 0; i < nd... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 461 | 2 |
#include <iostream>
using namespace std;
#define NIL -1;
struct Node {
int parent, left, right;
};
Node T[600000];
int D[600000];
int getDepth(int u) {
int d = 0;
while (T[u].parent != -1) {
u = T[u].parent;
d++;
}
return d;
}
void setDepth(int u, int p) {
D[u] = p;
if (T[u].right != -1)
... |
#include <iostream>
using namespace std;
#define NIL -1;
struct Node {
int parent, left, right;
};
Node T[600000];
int D[600000];
int getDepth(int u) {
int d = 0;
while (T[u].parent != -1) {
u = T[u].parent;
d++;
}
return d;
}
void setDepth(int u, int p) {
D[u] = p;
if (T[u].right != -1)
... | [["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 498 | 2 |
#include <iostream>
#include <stdio.h>
using namespace std;
const static int MAX = 100000;
const static int NIL = -1;
typedef struct {
int parent;
int left;
int right;
} Node;
Node T[MAX];
int D[MAX];
void printChildren(int u) {
int c = T[u].left;
int i = 0;
printf("[");
while (c != NIL) {
if (i ... | #include <iostream>
#include <stdio.h>
using namespace std;
const static int MAX = 100000;
const static int NIL = -1;
typedef struct {
int parent;
int left;
int right;
} Node;
Node T[MAX];
int D[MAX];
void printChildren(int u) {
int c = T[u].left;
int i = 0;
printf("[");
while (c != NIL) {
if (i ... | [["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]] | 1 | 525 | 2 |
class Node
attr_accessor :parent, :left, :right
def initialize(p, l, r)
@parent = p
@left = l
@right = r
end
end
def make_tree n
tree = {}
[*0...n].each do |i|
tree[i] = Node.new(-1, nil ,nil)
end
n.times do
k, l, r = gets.chomp.split.map(&:to_i)
... | class Node
attr_accessor :parent, :left, :right
def initialize(p, l, r)
@parent = p
@left = l
@right = r
end
end
def make_tree n
tree = {}
[*0...n].each do |i|
tree[i] = Node.new(-1, nil ,nil)
end
n.times do
k, l, r = gets.chomp.split.map(&:to_i)
... | [["-", 0, 652, 196, 737, 8, 736, 0, 652, 735, 22], ["-", 8, 736, 0, 652, 3, 4, 0, 652, 486, 22], ["-", 8, 736, 0, 652, 3, 4, 0, 652, 17, 131], ["-", 8, 736, 0, 652, 3, 4, 0, 652, 735, 22]] | 4 | 345 | 4 |
class Node
attr_accessor :key, :left, :right
def initialize(arr)
@key = arr[0]
@left = arr[1]
@right = arr[2]
end
def preorder
print " ", key
left.preorder if left != -1
right.preorder if right != -1
end
def inorder
left.inorder if left != -1
print " ", key
right.inorder ... | class Node
attr_accessor :key, :left, :right
def initialize(arr)
@key = arr[0]
@left = arr[1]
@right = arr[2]
end
def preorder
print " ", key
left.preorder if left != -1
right.preorder if right != -1
end
def inorder
left.inorder if left != -1
print " ", key
right.inorder ... | [["+", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["+", 36, 36, 36, 36, 36, 36, 0, 493, 0, 22]] | 4 | 270 | 3 |
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
vector<int> parent;
vector<int> L;
vector<int> R;
vector<int> d(10005);
vector<int> h(10005);
int n;
void Depth(int i, int x) {
if (i == -1)
return;
d[i] = x;
Depth(L[i], x + 1);
Depth(R[i], x + 1);
}
int Height(int i) {
i... | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
vector<int> parent;
vector<int> L;
vector<int> R;
vector<int> d(10005);
vector<int> h(10005);
int n;
void Depth(int i, int x) {
if (i == -1)
return;
d[i] = x;
Depth(L[i], x + 1);
Depth(R[i], x + 1);
}
int Height(int i) {
i... | [["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 621 | 12 |
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#defi... | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#defi... | [["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 355], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 354]] | 1 | 713 | 2 |
#include <stdio.h>
struct Node {
int l, p, r, b;
} T[28];
int D[30], H[30], n, DE[30];
void jiedian(int p, int u) {
if (p == -1)
return;
D[p] = u;
jiedian(T[p].l, u + 1);
jiedian(T[p].r, u + 1);
}
int pops(int u) {
if (H[u] == 0)
return 0;
int h1 = pops(T[u].r) + 1;
int h2 = pops(T[u].l) + 1;
... | #include <stdio.h>
struct Node {
int l, p, r, b;
} T[100];
int D[100], H[100], n, DE[100];
void jiedian(int p, int u) {
if (p == -1)
return;
D[p] = u;
jiedian(T[p].l, u + 1);
jiedian(T[p].r, u + 1);
}
int pops(int u) {
if (H[u] == 0)
return 0;
int h1 = pops(T[u].r) + 1;
int h2 = pops(T[u].l) +... | [["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 541 | 12 |
#include <iostream>
using namespace std;
#define MAX 25
#define NIL -1
struct Node {
int parent, left, right;
};
Node T[MAX];
int depth(int i) {
int count = 0;
int c = i;
while (T[c].parent != NIL) {
c = T[c].parent;
count++;
}
return count;
}
int height(int i) {
if (T[i].left == NIL && T[... | #include <iostream>
using namespace std;
#define MAX 25
#define NIL -1
struct Node {
int parent, left, right;
};
Node T[MAX];
int depth(int i) {
int count = 0;
int c = i;
while (T[c].parent != NIL) {
c = T[c].parent;
count++;
}
return count;
}
int height(int i) {
if (T[i].left == NIL && T[... | [["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 663 | 2 |
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, num, n) for (ll i = num, i##_len = (n); i < i##_len; ++i)
#define repprev(i, a, b) for (ll i = b - 1; i >= a; i--)
#define reprev(i, n) repprev(i, 0, n)
u... | #include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, num, n) for (ll i = num, i##_len = (n); i < i##_len; ++i)
#define repprev(i, a, b) for (ll i = b - 1; i >= a; i--)
#define reprev(i, n) repprev(i, 0, n)
u... | [["-", 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,618 | 6 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef pair<ll, ll> P;
struct P {
int p, l, r;
};
P T[30];
int D[30], H[30];
void depth(int v, int d) {
if (v == -1)
return;
D[v] = d;
depth(T[v].l, d + 1);
depth(T[v].r, d + 1);
}
int hight(int v) {
if (v == -1)
return -1;
... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef pair<ll, ll> P;
struct P {
int p, l, r;
};
P T[30];
int D[30], H[30];
void depth(int v, int d) {
if (v == -1)
return;
D[v] = d;
depth(T[v].l, d + 1);
depth(T[v].r, d + 1);
}
int hight(int v) {
if (v == -1)
return -1;
... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 597 | 2 |
#include <iostream>
#include <string>
using namespace std;
class Node {
public:
int l, r, p;
int deg, sib, dep, hig;
string typ;
};
Node nodes[25];
int top(int id, int tp) {
if (nodes[id].p != -1) {
return top(nodes[id].p, tp + 1);
}
return tp;
}
int dfs(int id, int dep) {
if (nodes[id].r != -1 ||... | #include <iostream>
#include <string>
using namespace std;
class Node {
public:
int l, r, p;
int deg, sib, dep, hig;
string typ;
};
Node nodes[25];
int top(int id, int tp) {
if (nodes[id].p != -1) {
return top(nodes[id].p, tp + 1);
}
return tp;
}
int dfs(int id, int dep) {
if (nodes[id].r != -1 ||... | [["+", 0, 57, 64, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 51, 13]] | 1 | 632 | 2 |
#include <cstdio>
using namespace std;
#define NIL -1
struct Node {
int parent, left, right;
};
Node T[30];
int n, D[30], H[30];
void setDepth(int i, int d) {
if (i == NIL)
return;
D[i] = d;
setDepth(T[i].left, d + 1);
setDepth(T[i].right, d + 1);
}
int setHeight(int i) {
int h1 = 0, h2 = 0;
if (T[... | #include <cstdio>
using namespace std;
#define NIL -1
struct Node {
int parent, left, right;
};
Node T[30];
int n, D[30], H[30];
void setDepth(int i, int d) {
if (i == NIL)
return;
D[i] = d;
setDepth(T[i].left, d + 1);
setDepth(T[i].right, d + 1);
}
int setHeight(int i) {
int h1 = 0, h2 = 0;
if (T[... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 593 | 2 |
#include <bits/stdc++.h>
using namespace std;
static const int NIL = -1;
struct Node {
int parent;
int left;
int right;
Node(int parent = NIL, int left = NIL, int right = NIL)
: parent(parent), left(left), right(right) {}
};
vector<Node> T;
vector<int> D;
vector<int> H;
void setDepth(int u, int depth)... | #include <bits/stdc++.h>
using namespace std;
static const int NIL = -1;
struct Node {
int parent;
int left;
int right;
Node(int parent = NIL, int left = NIL, int right = NIL)
: parent(parent), left(left), right(right) {}
};
vector<Node> T;
vector<int> D;
vector<int> H;
void setDepth(int u, int depth)... | [["-", 75, 76, 0, 1, 0, 11, 12, 5, 0, 6], ["+", 75, 76, 0, 1, 0, 11, 12, 5, 0, 6]] | 1 | 688 | 2 |
/*! if g++ -g alds_1_7_b.cpp -o alds_1_7_b.out; then ./alds_1_7_b.out <
* alds_1_7_b.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_b.cpp -o alds_1_7_b.out; then ./alds_1_7_b.out <
* alds_1_7_b.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... | [["-", 0, 14, 8, 9, 0, 37, 0, 5, 0, 6], ["+", 0, 14, 8, 9, 0, 37, 0, 5, 0, 6]] | 1 | 687 | 2 |
#include <algorithm>
#include <cassert>
#include <iostream>
#include <iterator>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef enum { ROOT, LEAF, INTR } LEAF_TYPE;
string lt2str(LEAF_TYPE lt) {
switch (lt) {
case ROOT:
return "root";
case LEAF:
return "leaf";
case ... | #include <algorithm>
#include <cassert>
#include <iostream>
#include <iterator>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef enum { ROOT, LEAF, INTR } LEAF_TYPE;
string lt2str(LEAF_TYPE lt) {
switch (lt) {
case ROOT:
return "root";
case LEAF:
return "leaf";
case ... | [["-", 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 | 642 | 4 |
#include <cstdio>
#define N 26
#define Nil -1
typedef struct {
int parent;
int left;
int right;
} Node;
Node BT[N];
int D[N];
int Deg[N];
int H[N];
void setDepth(int i, int depth) {
D[i] = depth;
if (BT[i].left != Nil)
setDepth(BT[i].left, depth + 1);
if (BT[i].right != Nil)
setDepth(BT[i].right,... | #include <cstdio>
#define N 26
#define Nil -1
typedef struct {
int parent;
int left;
int right;
} Node;
Node BT[N];
int D[N];
int Deg[N];
int H[N];
void setDepth(int i, int depth) {
D[i] = depth;
if (BT[i].left != Nil)
setDepth(BT[i].left, depth + 1);
if (BT[i].right != Nil)
setDepth(BT[i].right,... | [["-", 0, 2, 3, 4, 0, 61, 0, 5, 0, 6], ["+", 0, 2, 3, 4, 0, 61, 0, 5, 0, 6]] | 1 | 673 | 2 |
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define MAX 100001
#define NIL -1
struct Node {
int p, l, r;
};
Node T[MAX];
int n, D[MAX], H[MAX];
void setDepth(int u, int p) {
D[u] = p;
if (T[u].r != NIL)
setDepth(T[u].r, p + 1);
if (T[u].l != NIL)
setDepth(T[u].l, p ... | #include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define MAX 100001
#define NIL -1
struct Node {
int p, l, r;
};
Node T[MAX];
int n, D[MAX], H[MAX];
void setDepth(int u, int p) {
D[u] = p;
if (T[u].r != NIL)
setDepth(T[u].r, p + 1);
if (T[u].l != NIL)
setDepth(T[u].l, p ... | [["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 654 | 2 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define FOR(i, l, r) for (i = (l); i < r; i++)
using namespace std;
typedef long long ll;
typedef struct {
int p; // parent
int l; // left child
int r; // ... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define FOR(i, l, r) for (i = (l); i < r; i++)
using namespace std;
typedef long long ll;
typedef struct {
int p; // parent
int l; // left child
int r; // ... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 694 | 36 |
#include <algorithm>
#include <iostream>
using namespace std;
int get_height(int node, int left[], int right[], int height[]);
int get_depth(int node, int parent[], int depth[]);
void show_info(int node, int parent[], int sibling[], int degree[], int depth[],
int height[]);
int main() {
int parent[26... | #include <algorithm>
#include <iostream>
using namespace std;
int get_height(int node, int left[], int right[], int height[]);
int get_depth(int node, int parent[], int depth[]);
void show_info(int node, int parent[], int sibling[], int degree[], int depth[],
int height[]);
int main() {
int parent[26... | [["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]] | 1 | 709 | 2 |
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
class Node {
private:
int id;
int parent_id;
int sibling;
int degree;
int depth;
int height;
const char *type;
Node *parent;
Node *left;
Node *right;
public:
Node()
: id(-1), parent_id(-1), sibling(-1), degree(0... | #include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
class Node {
private:
int id;
int parent_id;
int sibling;
int degree;
int depth;
int height;
const char *type;
Node *parent;
Node *left;
Node *right;
public:
Node()
: id(-1), parent_id(-1), sibling(-1), degree(0... | [["-", 0, 2, 3, 4, 0, 61, 0, 5, 0, 6], ["+", 0, 2, 3, 4, 0, 61, 0, 5, 0, 6]] | 1 | 718 | 2 |
/*
* File: BinaryTree.cpp
* Author: masa
*
* Created on 2016/03/04, 9:14
*/
#include <cstdlib>
#include <iostream>
#define MAX 26
#define NIL -1
using namespace std;
/*
*
*/
struct Node {
int parent;
int left;
int right;
};
Node TreeNodeList[MAX];
int DepthList[MAX];
int HeightList[MAX];
void setDe... | /*
* File: BinaryTree.cpp
* Author: masa
*
* Created on 2016/03/04, 9:14
*/
#include <cstdlib>
#include <iostream>
#define MAX 26
#define NIL -1
using namespace std;
/*
*
*/
struct Node {
int parent;
int left;
int right;
};
Node TreeNodeList[MAX];
int DepthList[MAX];
int HeightList[MAX];
void setDe... | [["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 106]] | 1 | 769 | 2 |
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_7_B: Binary Trees
#include <algorithm>
#include <cstdio>
class BinaryTree {
public:
static const int NIL = -1;
struct Node {
// id is index of nodes_
int parent = NIL;
int left = NIL;
int right = NIL;
unsigned int depth = 0u;
u... | // -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_7_B: Binary Trees
#include <algorithm>
#include <cstdio>
class BinaryTree {
public:
static const int NIL = -1;
struct Node {
// id is index of nodes_
int parent = NIL;
int left = NIL;
int right = NIL;
unsigned int depth = 0u;
u... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 741 | 2 |
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
static const int SIZE = 100;
static const int NIL = -1;
struct Node {
int parent;
int left;
int right;
};
vector<Node> T(SIZE);
int n;
vector<int> D(SIZE);
vector<int> H(SIZE);
void setDepth(int u, int d) {
if (u == NIL) {
r... | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
static const int SIZE = 100;
static const int NIL = -1;
struct Node {
int parent;
int left;
int right;
};
vector<Node> T(SIZE);
int n;
vector<int> D(SIZE);
vector<int> H(SIZE);
void setDepth(int u, int d) {
if (u == NIL) {
r... | [["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 746 | 2 |
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
struct node {
int parent, left, right, sibling;
int depth, height;
node() {
parent = -1;
depth = -2;
height = -2;
}
};
vector<node> tree;
int traverse(int id, int current_depth) {
if (id == -1) {
return -1;
}
... | #include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
struct node {
int parent, left, right, sibling;
int depth, height;
node() {
parent = -1;
depth = -2;
height = -2;
}
};
vector<node> tree;
int traverse(int id, int current_depth) {
if (id == -1) {
return -1;
}
... | [["-", 0, 2, 3, 4, 0, 61, 0, 5, 0, 6], ["+", 0, 2, 3, 4, 0, 61, 0, 5, 0, 6]] | 1 | 496 | 2 |
#include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;
struct node {
int parent_id;
int left_child_id;
int right_child_id;
int sibling_id;
};
void print_children(int *children, int size);
int get_depth(node *b, int id);
int get_degree(node *b, int id);
int get_height(node *b, int id)... | #include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;
struct node {
int parent_id;
int left_child_id;
int right_child_id;
int sibling_id;
};
void print_children(int *children, int size);
int get_depth(node *b, int id);
int get_degree(node *b, int id);
int get_height(node *b, int id)... | [["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 659 | 2 |
#include <iostream>
using namespace std;
#define NIL -1
//二分木の節点
struct Node {
int parent, left, right;
};
Node T[1000000];
int n, D[1000000], H[1000000];
//二分木の節点の深さ
void setDepth(int u, int d) {
if (u == NIL)
return;
D[u] = d;
setDepth(T[u].left, d + 1);
setDepth(T[u].right, d + 1);
}
//二分木の節点の高さ
in... | #include <iostream>
using namespace std;
#define NIL -1
//二分木の節点
struct Node {
int parent, left, right;
};
Node T[1000000];
int n, D[1000000], H[1000000];
//二分木の節点の深さ
void setDepth(int u, int d) {
if (u == NIL)
return;
D[u] = d;
setDepth(T[u].left, d + 1);
setDepth(T[u].right, d + 1);
}
//二分木の節点の高さ
in... | [["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]] | 1 | 685 | 6 |
#include <bits/stdc++.h>
using namespace std;
#define REP(asd, fgh) for (int asd = 0; asd < fgh; asd++)
int n;
class Node {
public:
int p;
int depth;
int height;
int sibling;
int degree;
string type;
};
vector<Node> ans;
vector<vector<int>> t;
int dfs(int ind, int prev, int depth) {
ans[ind].p = prev;... | #include <bits/stdc++.h>
using namespace std;
#define REP(asd, fgh) for (int asd = 0; asd < fgh; asd++)
int n;
class Node {
public:
int p;
int depth;
int height;
int sibling;
int degree;
string type;
};
vector<Node> ans;
vector<vector<int>> t;
int dfs(int ind, int prev, int depth) {
ans[ind].p = prev;... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]] | 1 | 645 | 2 |
#include <bits/stdc++.h>
using namespace std;
int root;
int t[2][100000], hight[100000];
int dfs(int p) {
if (p == -1)
return -1;
return hight[p] = max(dfs(t[0][p]), dfs(t[1][p])) + 1;
}
int main() {
int root;
int n, par[100000], sib[100000];
cin >> n;
for (int i = 0; i < n; i++)
par[i] = -1;
for... | #include <bits/stdc++.h>
using namespace std;
int root;
int t[2][100000], hight[100000];
int dfs(int p) {
if (p == -1)
return -1;
return hight[p] = max(dfs(t[0][p]), dfs(t[1][p])) + 1;
}
int main() {
int root;
int n, par[100000], sib[100000];
cin >> n;
for (int i = 0; i < n; i++)
sib[i] = par[i] = ... | [["+", 0, 7, 8, 1, 0, 11, 31, 69, 28, 22], ["+", 8, 1, 0, 11, 31, 69, 341, 342, 0, 70], ["+", 8, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 8, 1, 0, 11, 31, 69, 341, 342, 0, 73], ["+", 8, 9, 0, 7, 8, 1, 0, 11, 17, 32]] | 1 | 421 | 5 |
#include <bits/stdc++.h>
using namespace std;
struct node {
int par, l, r, sib, deg, h;
};
node N[30];
int get_dep(int x, int dep) {
if (N[x].par == -1)
return dep;
return get_dep(N[x].par, dep + 1);
}
int mk_h(int x) {
int res = 0;
if (N[x].l != -1)
mk_h(N[x].l), res = N[N[x].l].h + 1;
if (N[x].r... | #include <bits/stdc++.h>
using namespace std;
struct node {
int par, l, r, sib, deg, h;
};
node N[30];
int get_dep(int x, int dep) {
if (N[x].par == -1)
return dep;
return get_dep(N[x].par, dep + 1);
}
int mk_h(int x) {
int res = 0;
if (N[x].l != -1)
mk_h(N[x].l), res = N[N[x].l].h + 1;
if (N[x].r... | [["-", 0, 2, 3, 4, 0, 61, 0, 5, 0, 6], ["+", 0, 2, 3, 4, 0, 61, 0, 5, 0, 6]] | 1 | 560 | 4 |
#include <algorithm>
#include <iostream>
using namespace std;
const int MAX = 10000;
const int NIL = -1;
struct Node {
int p;
int l;
int r;
};
Node T[MAX];
int n, D[MAX], H[MAX];
void setDepth(int u, int d) {
if (u == NIL)
return;
D[u] = d;
setDepth(T[u].l, d + 1);
setDepth(T[u].r, d + 1);
}
int ... | #include <algorithm>
#include <iostream>
using namespace std;
const int MAX = 10000;
const int NIL = -1;
struct Node {
int p;
int l;
int r;
};
Node T[MAX];
int n, D[MAX], H[MAX];
void setDepth(int u, int d) {
if (u == NIL)
return;
D[u] = d;
setDepth(T[u].l, d + 1);
setDepth(T[u].r, d + 1);
}
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 | 640 | 4 |
#include <iostream>
using namespace std;
#define N 25
#define rep(i, a) for (int i = 0; i < a; i++)
int n, a, l[N], r[N], par[N], sib[N], deg[N], dep[N], height[N], z[N];
bool used[N];
int dfs(int x, int d) {
dep[x] = d;
if (l[x] == -1 && r[x] == -1)
return 1;
if (z[x] != 2)
z[x] = 1;
if (l[x] != -1)... | #include <iostream>
using namespace std;
#define N 25
#define rep(i, a) for (int i = 0; i < a; i++)
int n, a, l[N], r[N], par[N], sib[N], deg[N], dep[N], height[N], z[N];
bool used[N];
int dfs(int x, int d) {
dep[x] = d;
if (l[x] == -1 && r[x] == -1)
return 1;
if (z[x] != 2)
z[x] = 1;
if (l[x] != -1)... | [["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]] | 1 | 485 | 2 |
#include <cassert>
#include <iostream>
#include <list>
#include <sstream>
#include <vector>
enum TNodeType { ntRoot, ntInternal, ntLeaf };
template <typename T> class TTree;
template <typename T> class TNode {
const T FValue;
TNode *FParent;
TNode *FLeft;
TNode *FRight;
public:
TNode(const T &Value) : FVal... | #include <cassert>
#include <iostream>
#include <list>
#include <sstream>
#include <vector>
enum TNodeType { ntRoot, ntInternal, ntLeaf };
template <typename T> class TTree;
template <typename T> class TNode {
const T FValue;
TNode *FParent;
TNode *FLeft;
TNode *FRight;
public:
TNode(const T &Value) : FVal... | [["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 1,072 | 2 |
#include <cstdio>
#include <iostream>
#define MAX 10000
#define NIL -1
struct Node {
int parent;
int left;
int right;
};
Node T[MAX];
int n, D[MAX], H[MAX];
void setDepth(int u, int d) {
if (u == NIL) {
return;
}
D[u] = d;
setDepth(T[u].left, d + 1);
setDepth(T[u].right, d + 1);
}
int setHeigh... | #include <cstdio>
#include <iostream>
#define MAX 10000
#define NIL -1
struct Node {
int parent;
int left;
int right;
};
Node T[MAX];
int n, D[MAX], H[MAX];
void setDepth(int u, int d) {
if (u == NIL) {
return;
}
D[u] = d;
setDepth(T[u].left, d + 1);
setDepth(T[u].right, d + 1);
}
int setHeigh... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]] | 1 | 705 | 4 |
#include <algorithm>
#include <stdio.h>
#include <string>
#define MAX 100000
#define NIL -1
struct Node {
public:
int id;
int parent;
int left;
int right;
int height;
int depth;
int sibling;
int degree;
};
Node N[MAX];
void setDepth(Node &n, int depth) {
Node *cur = &n;
cur->depth = depth;
if ... | #include <algorithm>
#include <stdio.h>
#include <string>
#define MAX 100000
#define NIL -1
struct Node {
public:
int id;
int parent;
int left;
int right;
int height;
int depth;
int sibling;
int degree;
};
Node N[MAX];
void setDepth(Node &n, int depth) {
Node *cur = &n;
cur->depth = depth;
if ... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]] | 1 | 631 | 2 |
#include <algorithm>
#include <iostream>
using namespace std;
struct node {
int parent, left, right;
};
int getroot(node);
const int nil = -1;
int D[30], H[30];
node N[30];
void setdepth(int, int);
int setheight(int);
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
N[i].parent = N[i].left = N[i].... | #include <algorithm>
#include <iostream>
using namespace std;
struct node {
int parent, left, right;
};
int getroot(node);
const int nil = -1;
int D[30], H[30];
node N[30];
void setdepth(int, int);
int setheight(int);
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
N[i].parent = N[i].left = N[i].... | [["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 621 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.