diff --git a/src/a.out b/src/a.out deleted file mode 100755 index 8553840..0000000 Binary files a/src/a.out and /dev/null differ diff --git a/src/chunyou b/src/chunyou deleted file mode 100755 index 32869c5..0000000 Binary files a/src/chunyou and /dev/null differ diff --git a/src/dikaer_tree.cpp b/src/dikaer_tree.cpp new file mode 100644 index 0000000..442e05a --- /dev/null +++ b/src/dikaer_tree.cpp @@ -0,0 +1,40 @@ +#include +#include + +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; +} diff --git a/src/noip2011_program.cpp b/src/noip2011_program.cpp new file mode 100644 index 0000000..5f8b595 --- /dev/null +++ b/src/noip2011_program.cpp @@ -0,0 +1,43 @@ +#include + +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; +} diff --git a/src/noip2013_binary_search_tree.cpp b/src/noip2013_binary_search_tree.cpp new file mode 100644 index 0000000..26205b5 --- /dev/null +++ b/src/noip2013_binary_search_tree.cpp @@ -0,0 +1,31 @@ +#include +#include + +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; +} diff --git a/src/passwd_check b/src/passwd_check deleted file mode 100755 index 258ae2d..0000000 Binary files a/src/passwd_check and /dev/null differ diff --git a/src/test b/src/test deleted file mode 100755 index 3a96261..0000000 Binary files a/src/test and /dev/null differ diff --git a/src/tudeoulalu b/src/tudeoulalu deleted file mode 100755 index adf44de..0000000 Binary files a/src/tudeoulalu and /dev/null differ