Removed some files

This commit is contained in:
Hmtsai 2024-04-21 15:48:24 +08:00
parent 2c8da23eb1
commit 089a857613
8 changed files with 114 additions and 0 deletions

BIN
src/a.out

Binary file not shown.

Binary file not shown.

40
src/dikaer_tree.cpp Normal file
View File

@ -0,0 +1,40 @@
#include <cmath>
#include <iostream>
const int SIZE = 100 + 5;
int n, a[SIZE], maxDeep, num;
void solve(int left, int right, int deep) {
int i, j, min;
if (deep > maxDeep) {
maxDeep = deep;
num = 1;
} else if (deep == maxDeep) {
num++;
}
min = INFINITY;
for (i = left; i <= right; i++) {
if (min > a[i]) {
min = a[i];
j = i;
}
}
if (left < j) {
solve(left, j - 1, deep + 1);
}
if (j < right) {
solve(j, right, deep + 1);
}
}
int main() {
int i;
std::cin >> n;
for (i = 1; i <= n; i++) {
std::cin >> a[i];
}
maxDeep = 0;
solve(1, n, 1);
std::cout << maxDeep << " " << num << std::endl;
return 0;
}

43
src/noip2011_program.cpp Normal file
View File

@ -0,0 +1,43 @@
#include <iostream>
const int V = 100;
int n, m, ans, e[V][V];
bool visited[V];
void dfs(int x, int len) {
int i;
visited[x] = true;
if (len > ans) {
ans = len;
}
for (i = 1; i <= n; i++) {
if ((!visited[i]) && (e[x][i] != -1)) {
dfs(i, len + e[x][i]);
}
}
visited[x] = false;
}
int main() {
int i, j, a, b, c;
std::cin >> n >> m;
for (i = 1; i <= n; i++) {
for (j = 1; j <= m; j++) {
e[i][j] = -1;
}
}
for (i = 1; i <= m; i++) {
std::cin >> a >> b >> c;
e[a][b] = c;
e[b][a] = c;
}
for (i = 1; i <= n; i++) {
visited[i] = false;
}
ans = 0;
for (i = 1; i <= n; i++) {
dfs(i, 0);
}
std::cout << ans << std::endl;
return 0;
}

View File

@ -0,0 +1,31 @@
#include <cmath>
#include <iostream>
const int SIZE = 100;
struct node {
int left_child, right_child, value;
} a[SIZE];
int is_bst(int root, int lower_bound, int upper_bound) {
int cur;
if (root == 0) {
return 1;
}
cur = a[root].value;
if ((cur > lower_bound) && (cur < upper_bound) &&
(is_bst(a[root].left_child, lower_bound, cur) == 1) &&
(is_bst(a[root].right_child, cur + 1, upper_bound) == 1)) {
return 1;
}
return 0;
}
int main() {
int i, n;
std::cin >> n;
for (i = 1; i <= n; i++) {
std::cin >> a[i].value >> a[i].left_child >> a[i].right_child;
}
std::cout << is_bst(1, -INFINITY, INFINITY) << std::endl;
return 0;
}

Binary file not shown.

BIN
src/test

Binary file not shown.

Binary file not shown.